├── .gitarchivever
├── .gitattributes
├── .gitignore
├── LICENSE
├── Makefile.am
├── README
├── autogen.sh
├── build-aux
├── git-version-gen
├── gitlog-to-changelog
└── release.mk
├── configure.ac
├── corosync-qdevice.pc.in
├── corosync-qdevice.spec.in
├── init
├── .gitignore
├── Makefile.am
├── corosync-qdevice.in
├── corosync-qdevice.service.in
├── corosync-qdevice.sysconfig.example
├── corosync-qnetd.in
├── corosync-qnetd.service.in
├── corosync-qnetd.sysconfig.example
└── corosync-qnetd.sysusers.conf.example
├── man
├── .gitignore
├── Makefile.am
├── corosync-qdevice-net-certutil.8
├── corosync-qdevice-tool.8
├── corosync-qdevice.8
├── corosync-qnetd-certutil.8
├── corosync-qnetd-tool.8
└── corosync-qnetd.8
└── qdevices
├── .gitignore
├── Makefile.am
├── corosync-qdevice-net-certutil.sh
├── corosync-qdevice-tool.c
├── corosync-qdevice.c
├── corosync-qnetd-certutil.sh
├── corosync-qnetd-tool.c
├── corosync-qnetd.c
├── dynar-getopt-lex.c
├── dynar-getopt-lex.h
├── dynar-simple-lex.c
├── dynar-simple-lex.h
├── dynar-str.c
├── dynar-str.h
├── dynar.c
├── dynar.h
├── log-common.c
├── log-common.h
├── log.c
├── log.h
├── msg.c
├── msg.h
├── msgio.c
├── msgio.h
├── node-list.c
├── node-list.h
├── nss-sock.c
├── nss-sock.h
├── pr-poll-array.c
├── pr-poll-array.h
├── pr-poll-loop.c
├── pr-poll-loop.h
├── process-list.c
├── process-list.h
├── qdevice-advanced-settings.c
├── qdevice-advanced-settings.h
├── qdevice-cmap.c
├── qdevice-cmap.h
├── qdevice-config.h
├── qdevice-heuristics-cmd-str.h
├── qdevice-heuristics-cmd.c
├── qdevice-heuristics-cmd.h
├── qdevice-heuristics-exec-list.c
├── qdevice-heuristics-exec-list.h
├── qdevice-heuristics-exec-result.c
├── qdevice-heuristics-exec-result.h
├── qdevice-heuristics-instance.c
├── qdevice-heuristics-instance.h
├── qdevice-heuristics-io.c
├── qdevice-heuristics-io.h
├── qdevice-heuristics-log.c
├── qdevice-heuristics-log.h
├── qdevice-heuristics-mode.c
├── qdevice-heuristics-mode.h
├── qdevice-heuristics-result-notifier.c
├── qdevice-heuristics-result-notifier.h
├── qdevice-heuristics-worker-cmd.c
├── qdevice-heuristics-worker-cmd.h
├── qdevice-heuristics-worker-instance.h
├── qdevice-heuristics-worker-log.c
├── qdevice-heuristics-worker-log.h
├── qdevice-heuristics-worker.c
├── qdevice-heuristics-worker.h
├── qdevice-heuristics.c
├── qdevice-heuristics.h
├── qdevice-instance.c
├── qdevice-instance.h
├── qdevice-ipc-cmd.c
├── qdevice-ipc-cmd.h
├── qdevice-ipc.c
├── qdevice-ipc.h
├── qdevice-log.c
├── qdevice-log.h
├── qdevice-model-net.c
├── qdevice-model-net.h
├── qdevice-model-type.h
├── qdevice-model.c
├── qdevice-model.h
├── qdevice-net-algo-2nodelms.c
├── qdevice-net-algo-2nodelms.h
├── qdevice-net-algo-ffsplit.c
├── qdevice-net-algo-ffsplit.h
├── qdevice-net-algo-lms.c
├── qdevice-net-algo-lms.h
├── qdevice-net-algo-test.c
├── qdevice-net-algo-test.h
├── qdevice-net-algorithm.c
├── qdevice-net-algorithm.h
├── qdevice-net-cast-vote-timer.c
├── qdevice-net-cast-vote-timer.h
├── qdevice-net-disconnect-reason.h
├── qdevice-net-echo-request-timer.c
├── qdevice-net-echo-request-timer.h
├── qdevice-net-heuristics.c
├── qdevice-net-heuristics.h
├── qdevice-net-instance.c
├── qdevice-net-instance.h
├── qdevice-net-ipc-cmd.c
├── qdevice-net-ipc-cmd.h
├── qdevice-net-msg-received.c
├── qdevice-net-msg-received.h
├── qdevice-net-nss.c
├── qdevice-net-nss.h
├── qdevice-net-send.c
├── qdevice-net-send.h
├── qdevice-net-socket.c
├── qdevice-net-socket.h
├── qdevice-net-votequorum.c
├── qdevice-net-votequorum.h
├── qdevice-pr-poll-loop-cb.c
├── qdevice-pr-poll-loop-cb.h
├── qdevice-pr-poll-loop.c
├── qdevice-pr-poll-loop.h
├── qdevice-votequorum.c
├── qdevice-votequorum.h
├── qnet-config.h
├── qnetd-advanced-settings.c
├── qnetd-advanced-settings.h
├── qnetd-algo-2nodelms.c
├── qnetd-algo-2nodelms.h
├── qnetd-algo-ffsplit.c
├── qnetd-algo-ffsplit.h
├── qnetd-algo-lms.c
├── qnetd-algo-lms.h
├── qnetd-algo-test.c
├── qnetd-algo-test.h
├── qnetd-algo-utils.c
├── qnetd-algo-utils.h
├── qnetd-algorithm.c
├── qnetd-algorithm.h
├── qnetd-client-algo-timer.c
├── qnetd-client-algo-timer.h
├── qnetd-client-dpd-timer.c
├── qnetd-client-dpd-timer.h
├── qnetd-client-list.c
├── qnetd-client-list.h
├── qnetd-client-msg-received.c
├── qnetd-client-msg-received.h
├── qnetd-client-net.c
├── qnetd-client-net.h
├── qnetd-client-send.c
├── qnetd-client-send.h
├── qnetd-client.c
├── qnetd-client.h
├── qnetd-cluster-list.c
├── qnetd-cluster-list.h
├── qnetd-cluster.c
├── qnetd-cluster.h
├── qnetd-instance.c
├── qnetd-instance.h
├── qnetd-ipc-cmd.c
├── qnetd-ipc-cmd.h
├── qnetd-ipc.c
├── qnetd-ipc.h
├── qnetd-log-debug.c
├── qnetd-log-debug.h
├── send-buffer-list.c
├── send-buffer-list.h
├── test-dynar-getopt-lex.c
├── test-dynar-simple-lex.c
├── test-dynar.c
├── test-log.c
├── test-pr-poll-loop.c
├── test-process-list.c
├── test-qnetd-cluster-list.c
├── test-timer-list.c
├── test-utils.c
├── timer-list.c
├── timer-list.h
├── tlv.c
├── tlv.h
├── unix-socket-client-list.c
├── unix-socket-client-list.h
├── unix-socket-client.c
├── unix-socket-client.h
├── unix-socket-ipc.c
├── unix-socket-ipc.h
├── unix-socket.c
├── unix-socket.h
├── utils.c
└── utils.h
/.gitarchivever:
--------------------------------------------------------------------------------
1 | ref names: (HEAD -> main)
2 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | .gitarchivever export-subst
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.a
3 | *.so*
4 | *.lo
5 | *.la
6 | .libs
7 | .deps
8 | .version
9 | doc
10 | Makefile
11 | Makefile.in
12 | corosync-qdevice.spec
13 | corosync-qdevice.pc
14 | aclocal.m4
15 | autom4te.cache/
16 | compile
17 | config.guess
18 | config.log
19 | config.status
20 | config.sub
21 | configure
22 | corosync-*.tar*
23 | depcomp
24 | install-sh
25 | libtool
26 | ltmain.sh
27 | m4
28 | missing
29 | tags
30 | ID
31 | Doxyfile
32 | config.h*
33 | stamp-*
34 | test-driver
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | The following license applies to every file in this source distribution except
3 | for the files git-version-gen, and gitlog-to-changelog.
4 |
5 | The git* files, which are available under GPLv3 or later, are only used by
6 | our release process to generate text file content and are not part of any
7 | generated binary.
8 | -----------------------------------------------------------------------------
9 |
10 | Copyright (c) 2015-2020 Red Hat, Inc.
11 |
12 | All rights reserved.
13 |
14 | This software licensed under BSD license, the text of which follows:
15 |
16 | Redistribution and use in source and binary forms, with or without
17 | modification, are permitted provided that the following conditions are met:
18 |
19 | - Redistributions of source code must retain the above copyright notice,
20 | this list of conditions and the following disclaimer.
21 | - Redistributions in binary form must reproduce the above copyright notice,
22 | this list of conditions and the following disclaimer in the documentation
23 | and/or other materials provided with the distribution.
24 | - Neither the name of the Red Hat, Inc. nor the names of its
25 | contributors may be used to endorse or promote products derived from this
26 | software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
38 | THE POSSIBILITY OF SUCH DAMAGE.
39 |
40 | -----------------------------------------------------------------------------
41 | The corosync-qdevice project uses software for release processing which generates
42 | changelogs and version information for the software. These programs are not
43 | used by the generated binaries or libraries These files are git-version-gen
44 | and gitlog-to-changelog.
45 | -----------------------------------------------------------------------------
46 | The license for these files is as follows:
47 | This program is free software: you can redistribute it and/or modify
48 | it under the terms of the GNU General Public License as published by
49 | the Free Software Foundation, either version 3 of the License, or
50 | (at your option) any later version.
51 |
52 | This program is distributed in the hope that it will be useful,
53 | but WITHOUT ANY WARRANTY; without even the implied warranty of
54 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 | GNU General Public License for more details.
56 |
57 | You should have received a copy of the GNU General Public License
58 | along with this program. If not, see .
59 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Corosync-qdevice
2 | ----------------
3 | corosync-qdevice is a daemon running on each node of a cluster. It provides
4 | a configured number of votes to the quorum subsystem based on a third-party
5 | arbitrator's decision. Its primary use is to allow a cluster to sustain more
6 | node failures than standard quorum rules allow. It is recommended for clusters
7 | with an even number of nodes and highly recommended for 2 node clusters.
8 |
9 | corosync-qnetd is a daemon running outside of the cluster with the purpose
10 | of providing a vote to the corosync-qdevice model net. It's designed to
11 | support multiple clusters and be almost configuration and state free.
12 | New clusters are handled dynamically and no configuration file exists.
13 | It's also able to run as non-root user - which is recommended.
14 | Connection between the corosync-qdevice model net client can be optionally
15 | configured with TLS client certificate checking. The communication protocol
16 | between server and client is designed to be very simple and allow
17 | backwards compatibility.
18 |
19 | Originally both qdevice and qnetd were part of the Corosync codebase
20 | (https://github.com/corosync/corosync) but because it got quite big we
21 | decided to split it into its own sub-project.
22 |
23 | Dependencies
24 | ------------
25 | * Corosync >= 2.0
26 | * NSS
27 |
28 | Installation
29 | ------------
30 | $ ./autogen.sh
31 | $ ./configure
32 | $ make
33 | $ sudo make install
34 |
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Run this to generate all the initial makefiles, etc.
3 | mkdir -p m4
4 | echo Building configuration system...
5 | autoreconf -i && echo Now run ./configure and make
6 |
--------------------------------------------------------------------------------
/build-aux/release.mk:
--------------------------------------------------------------------------------
1 | # to build official release tarballs, handle tagging and publish.
2 |
3 | # signing key
4 | gpgsignkey=
5 |
6 | project=corosync-qdevice
7 |
8 | all: checks setup tag tarballs sha256 sign
9 |
10 | checks:
11 | ifeq (,$(version))
12 | @echo ERROR: need to define version=
13 | @exit 1
14 | endif
15 | @if [ ! -d .git ]; then \
16 | echo This script needs to be executed from top level cluster git tree; \
17 | exit 1; \
18 | fi
19 |
20 | setup: checks
21 | ./autogen.sh
22 | ./configure
23 | make maintainer-clean
24 |
25 | tag: setup ./tag-$(version)
26 |
27 | tag-$(version):
28 | ifeq (,$(release))
29 | @echo Building test release $(version), no tagging
30 | else
31 | git tag -a -m "v$(version) release" v$(version) HEAD
32 | @touch $@
33 | endif
34 |
35 | tarballs: tag
36 | ./autogen.sh
37 | ./configure
38 | make distcheck
39 |
40 | sha256: tarballs $(project)-$(version).sha256
41 |
42 | $(project)-$(version).sha256:
43 | ifeq (,$(release))
44 | @echo Building test release $(version), no sha256
45 | else
46 | sha256sum $(project)-$(version)*tar* | sort -k2 > $@
47 | endif
48 |
49 | sign: sha256 $(project)-$(version).sha256.asc
50 |
51 | $(project)-$(version).sha256.asc: $(project)-$(version).sha256
52 | ifeq (,$(gpgsignkey))
53 | @echo No GPG signing key defined
54 | else
55 | ifeq (,$(release))
56 | @echo Building test release $(version), no sign
57 | else
58 | gpg --default-key $(gpgsignkey) \
59 | --detach-sign \
60 | --armor \
61 | $<
62 | endif
63 | endif
64 |
65 | publish:
66 | ifeq (,$(release))
67 | @echo Building test release $(version), no publishing!
68 | else
69 | @echo CHANGEME git push --tags origin
70 | @echo CHANGEME scp $(project)-$(version).* \
71 | fedorahosted.org:$(project)
72 | endif
73 |
74 | clean:
75 | rm -rf $(project)-* tag-*
76 |
--------------------------------------------------------------------------------
/corosync-qdevice.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | confdir=@COROSYSCONFDIR@
4 |
5 | Name: @PACKAGE@
6 | Version: @VERSION@
7 | Description: @PACKAGE@ build information required for downstream projects
8 |
--------------------------------------------------------------------------------
/init/.gitignore:
--------------------------------------------------------------------------------
1 | corosync
2 | corosync-notifyd
3 | corosync.service
4 | corosync-notifyd.service
5 | corosync-qnetd
6 | corosync-qnetd.service
7 | corosync-qdevice
8 | corosync-qdevice.service
9 |
--------------------------------------------------------------------------------
/init/Makefile.am:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2004 MontaVista Software, Inc.
2 | # Copyright (c) 2009 - 2018 Red Hat, Inc.
3 | #
4 | # Authors: Jan Friesse (jfriesse@redhat.com)
5 | # Steven Dake (sdake@redhat.com)
6 | # Fabio M. Di Nitto (fdinitto@redhat.com)
7 | #
8 | # All rights reserved.
9 | #
10 | # This software licensed under BSD license, the text of which follows:
11 | #
12 | # Redistribution and use in source and binary forms, with or without
13 | # modification, are permitted provided that the following conditions are met:
14 | #
15 | # - Redistributions of source code must retain the above copyright notice,
16 | # this list of conditions and the following disclaimer.
17 | # - Redistributions in binary form must reproduce the above copyright notice,
18 | # this list of conditions and the following disclaimer in the documentation
19 | # and/or other materials provided with the distribution.
20 | # - Neither the name of the Red Hat, Inc. nor the names of its
21 | # contributors may be used to endorse or promote products derived from this
22 | # software without specific prior written permission.
23 | #
24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 | # THE POSSIBILITY OF SUCH DAMAGE.
35 |
36 | MAINTAINERCLEANFILES = Makefile.in
37 |
38 | EXTRA_DIST = corosync-qdevice.sysconfig.example corosync-qdevice.in \
39 | corosync-qdevice.service.in \
40 | corosync-qnetd.sysconfig.example corosync-qnetd.in \
41 | corosync-qnetd.service.in \
42 | corosync-qnetd.sysusers.conf.example
43 |
44 | if INSTALL_SYSTEMD
45 | systemdconfdir = $(SYSTEMDDIR)
46 | systemdconf_DATA =
47 | else
48 | initscriptdir = $(INITDDIR)
49 | initscript_SCRIPTS =
50 | endif
51 |
52 | if BUILD_QDEVICES
53 | if INSTALL_SYSTEMD
54 | systemdconf_DATA += corosync-qdevice.service
55 | else
56 | initscript_SCRIPTS += corosync-qdevice
57 | endif
58 | endif
59 |
60 | if BUILD_QNETD
61 | if INSTALL_SYSTEMD
62 | systemdconf_DATA += corosync-qnetd.service
63 | else
64 | initscript_SCRIPTS += corosync-qnetd
65 | endif
66 | endif
67 |
68 | if BUILD_INSTALL_QNETD_IN_SBIN
69 | qnetddir=$(sbindir)
70 | else
71 | qnetddir=$(bindir)
72 | endif
73 |
74 | %: %.in Makefile
75 | rm -f $@-t $@
76 | cat $< | sed \
77 | -e 's#@''SBINDIR@#$(sbindir)#g' \
78 | -e 's#@''BINDIR@#$(bindir)#g' \
79 | -e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \
80 | -e 's#@''INITCONFIGDIR@#$(INITCONFIGDIR)#g' \
81 | -e 's#@''INITDDIR@#$(INITDDIR)#g' \
82 | -e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
83 | -e 's#@''BASHPATH@#${BASHPATH}#g' \
84 | -e 's#@''QNETDDIR@#$(qnetddir)#g' \
85 | > $@-t
86 | mv $@-t $@
87 |
88 | all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)
89 |
90 | clean-local:
91 | rm -rf $(initscript_SCRIPTS) $(systemdconf_DATA)
92 |
--------------------------------------------------------------------------------
/init/corosync-qdevice.service.in:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Corosync Qdevice daemon
3 | Documentation=man:corosync-qdevice
4 | ConditionKernelCommandLine=!nocluster
5 | Requires=corosync.service
6 | After=corosync.service
7 |
8 | [Service]
9 | EnvironmentFile=-@INITCONFIGDIR@/corosync-qdevice
10 | ExecStart=@SBINDIR@/corosync-qdevice -f $COROSYNC_QDEVICE_OPTIONS
11 | Type=notify
12 | StandardError=null
13 | Restart=on-failure
14 | RuntimeDirectory=corosync-qdevice
15 | RuntimeDirectoryMode=0770
16 |
17 | [Install]
18 | WantedBy=multi-user.target
19 |
--------------------------------------------------------------------------------
/init/corosync-qdevice.sysconfig.example:
--------------------------------------------------------------------------------
1 | # Corosync Qdevice daemon init script configuration file
2 |
3 | # COROSYNC_QDEVICE_OPTIONS specifies options passed to corosync-qdevice command
4 | # (default is no options).
5 | # See "man corosync-qdevice" for detailed descriptions of the options.
6 | COROSYNC_QDEVICE_OPTIONS=""
7 |
--------------------------------------------------------------------------------
/init/corosync-qnetd.service.in:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Corosync Qdevice Network daemon
3 | Documentation=man:corosync-qnetd
4 | ConditionKernelCommandLine=!nocluster
5 | Requires=network-online.target
6 | After=network-online.target
7 |
8 | [Service]
9 | EnvironmentFile=-@INITCONFIGDIR@/corosync-qnetd
10 | ExecStart=@QNETDDIR@/corosync-qnetd -f $COROSYNC_QNETD_OPTIONS
11 | Type=notify
12 | StandardError=null
13 | Restart=on-abnormal
14 | # Uncomment and set user who should be used for executing qnetd
15 | #User=coroqnetd
16 | RuntimeDirectory=corosync-qnetd
17 | RuntimeDirectoryMode=0770
18 |
19 | [Install]
20 | WantedBy=multi-user.target
21 |
--------------------------------------------------------------------------------
/init/corosync-qnetd.sysconfig.example:
--------------------------------------------------------------------------------
1 | # Corosync Qdevice Network daemon init script configuration file
2 |
3 | # COROSYNC_QNETD_OPTIONS specifies options passed to corosync-qnetd command
4 | # (default is no options).
5 | # See "man corosync-qnetd" for detailed descriptions of the options.
6 | COROSYNC_QNETD_OPTIONS=""
7 |
8 | # COROSYNC_QNETD_RUNAS specifies user under which qnetd daemon should be running
9 | # (not set or empty is default and means "user who executes init script")
10 | # Make sure to set correct owner of directories /etc/corosync/qnetd and
11 | # /var/run/corosync-qnetd
12 | # This has no effect if systemd unit is used (you have to change unit file)
13 | COROSYNC_QNETD_RUNAS=""
14 |
--------------------------------------------------------------------------------
/init/corosync-qnetd.sysusers.conf.example:
--------------------------------------------------------------------------------
1 | u coroqnetd - 'User for corosync-qnetd' - -
2 |
--------------------------------------------------------------------------------
/man/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.3
3 |
--------------------------------------------------------------------------------
/man/Makefile.am:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2004 MontaVista Software, Inc.
2 | # Copyright (c) 2009 - 2018 Red Hat, Inc.
3 | #
4 | # Authors: Jan Friesse (jfriesse@redhat.com)
5 | # Steven Dake (sdake@redhat.com)
6 | # Fabio M. Di Nitto (fdinitto@redhat.com)
7 | #
8 | # All rights reserved.
9 | #
10 | # This software licensed under BSD license, the text of which follows:
11 | #
12 | # Redistribution and use in source and binary forms, with or without
13 | # modification, are permitted provided that the following conditions are met:
14 | #
15 | # - Redistributions of source code must retain the above copyright notice,
16 | # this list of conditions and the following disclaimer.
17 | # - Redistributions in binary form must reproduce the above copyright notice,
18 | # this list of conditions and the following disclaimer in the documentation
19 | # and/or other materials provided with the distribution.
20 | # - Neither the name of the Red Hat, Inc. nor the names of its
21 | # contributors may be used to endorse or promote products derived from this
22 | # software without specific prior written permission.
23 | #
24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 | # THE POSSIBILITY OF SUCH DAMAGE.
35 |
36 | MAINTAINERCLEANFILES = Makefile.in
37 |
38 | qnetd_man = corosync-qnetd-tool.8 \
39 | corosync-qnetd-certutil.8 \
40 | corosync-qnetd.8
41 |
42 | qdevices_man = corosync-qdevice-tool.8 \
43 | corosync-qdevice-net-certutil.8 \
44 | corosync-qdevice.8
45 |
46 | EXTRA_DIST = $(qnetd_man) \
47 | $(qdevices_man)
48 |
49 | dist_man_MANS =
50 |
51 | if BUILD_QNETD
52 | dist_man_MANS += $(qnetd_man)
53 | endif
54 |
55 | if BUILD_QDEVICES
56 | dist_man_MANS += $(qdevices_man)
57 | endif
58 |
59 | HTML_DOCS = $(dist_man_MANS:%=%.html) $(man_MANS:%=%.html)
60 |
61 | # developer man page generation
62 | %.3: %.3.in $(autogen_common)
63 | @echo Generating $@ man page && \
64 | rm -f $@-t-t $@-t $@ && \
65 | date="$$(LC_ALL=C date "+%F" $${SOURCE_DATE_EPOCH+-d @$$SOURCE_DATE_EPOCH})" && \
66 | awk "{print}(\$$1 ~ /@COMMONIPCERRORS@/){exit 0}" ${top_srcdir}/man/$@.in > $@-t-t && \
67 | cat ${top_srcdir}/man/$(autogen_common) >> $@-t-t && \
68 | awk -v p=0 "(\$$1 ~ /@COMMONIPCERRORS@/){p = 1} {if(p==1)print}" ${top_srcdir}/man/$@.in >> $@-t-t && \
69 | cat $@-t-t | \
70 | sed -e 's#@BUILDDATE@#'$$date'#g' \
71 | -e 's#@COMMONIPCERRORS@##g' \
72 | > $@-t && \
73 | rm -f $@-t-t && \
74 | mv $@-t $@
75 |
76 | clean-local:
77 | rm -rf $(HTML_DOCS) $(autogen_man)
78 |
79 | if BUILD_HTML_DOCS
80 | %.html: %
81 | $(GROFF) -mandoc -Thtml $^ > $@
82 |
83 | install-data-local:
84 | $(INSTALL) -d $(DESTDIR)/${docdir}/html
85 | $(INSTALL) -m 644 $(HTML_DOCS) $(DESTDIR)/${docdir}/html/
86 |
87 | uninstall-local:
88 | cd $(DESTDIR)/${docdir}/html && rm -f $(HTML_DOCS)
89 | rmdir $(DESTDIR)/${docdir}/html 2> /dev/null || :
90 |
91 | all-local: $(HTML_DOCS)
92 | endif
93 |
--------------------------------------------------------------------------------
/man/corosync-qdevice-net-certutil.8:
--------------------------------------------------------------------------------
1 | .\"/*
2 | .\" * Copyright (C) 2016 Red Hat, Inc.
3 | .\" *
4 | .\" * All rights reserved.
5 | .\" *
6 | .\" * Author: Jan Friesse
7 | .\" *
8 | .\" * This software licensed under BSD license, the text of which follows:
9 | .\" *
10 | .\" * Redistribution and use in source and binary forms, with or without
11 | .\" * modification, are permitted provided that the following conditions are met:
12 | .\" *
13 | .\" * - Redistributions of source code must retain the above copyright notice,
14 | .\" * this list of conditions and the following disclaimer.
15 | .\" * - Redistributions in binary form must reproduce the above copyright notice,
16 | .\" * this list of conditions and the following disclaimer in the documentation
17 | .\" * and/or other materials provided with the distribution.
18 | .\" * - Neither the name of Red Hat, Inc. nor the names of its
19 | .\" * contributors may be used to endorse or promote products derived from this
20 | .\" * software without specific prior written permission.
21 | .\" *
22 | .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | .\" * THE POSSIBILITY OF SUCH DAMAGE.
33 | .\" */
34 | .TH COROSYNC-QDEVICE-NET-CERTUTIL 8 2016-06-28
35 | .SH NAME
36 | corosync-qdevice-net-certutil - tool to generate qdevice model net TLS certificates
37 | .SH SYNOPSIS
38 | .B "corosync-qdevice-net-certutil [-i|-m|-M|-r|-s|-Q] [-c certificate] [-n cluster_name]"
39 | .SH DESCRIPTION
40 | .B corosync-qdevice-net-certutil
41 | is a frontend for NSS certutil used for generating client certificate for the net model of
42 | qdevice.
43 | .SH OPTIONS
44 | .TP
45 | .B -i
46 | Initialize the QDevice Net NSS certificate database.
47 | The default directory for the database is /etc/corosync/qdevice/net/. This directory
48 | has to be writable by the current user. It needs the QNetd CA certificate passed as the
49 | .B -c
50 | parameter. This certificate can be found on the server running QNetd in the file
51 | /etc/corosync/qnetd/nssdb/qnetd-cacert.crt.
52 | .TP
53 | .B -m
54 | Import the cluster certificate and key from a pk12 file.
55 | .TP
56 | .B -r
57 | Generate a certificate request. The certificate request is exported into
58 | /etc/corosync/qdevice/net/qdevice-net-node.crq. It is necessary to
59 | pass the cluster name using the
60 | .B -n
61 | parameter. The cluster name has to match the one defined in /etc/corosync/corosync.conf.
62 | .TP
63 | .B -M
64 | Import a signed certificate and export a certificate with private key into
65 | pk12 file.
66 | .TP
67 | .B -Q
68 | Use ssh/scp to properly set both
69 | .B corosync-qnetd
70 | and
71 | .B corosync-qdevice
72 | certificates on all nodes. It's highly recommended that you use an ssh agent,
73 | or ssh/scp will keep asking for a password - roughly 8 times the number of nodes.
74 | .TP
75 | .B -c
76 | File with certificate to load.
77 | .TP
78 | .B -n
79 | Name of the cluster.
80 | .SH SEE ALSO
81 | .BR corosync-qnetd (8)
82 | .BR corosync-qdevice (8)
83 | .SH AUTHOR
84 | Jan Friesse
85 | .PP
86 |
--------------------------------------------------------------------------------
/qdevices/.gitignore:
--------------------------------------------------------------------------------
1 | corosync-qdevice
2 | corosync-qdevice-tool
3 | corosync-qnetd-certutil
4 | corosync-qdevice-net-certutil
5 | corosync-qnetd
6 | corosync-qnetd-tool
7 |
8 | # Testsuite results
9 | *.test
10 | *.log
11 | *.trs
12 |
--------------------------------------------------------------------------------
/qdevices/dynar-getopt-lex.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _DYNAR_GETOPT_LEX_H_
36 | #define _DYNAR_GETOPT_LEX_H_
37 |
38 | #include "dynar.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | struct dynar_getopt_lex {
45 | struct dynar option;
46 | struct dynar value;
47 | struct dynar *input;
48 | size_t pos;
49 | };
50 |
51 | extern void dynar_getopt_lex_init(struct dynar_getopt_lex *lex, struct dynar *input);
52 |
53 | extern void dynar_getopt_lex_destroy(struct dynar_getopt_lex *lex);
54 |
55 | extern int dynar_getopt_lex_token_next(struct dynar_getopt_lex *lex);
56 |
57 | #ifdef __cplusplus
58 | }
59 | #endif
60 |
61 | #endif /* _DYNAR_GETOPT_LEX_H_ */
62 |
--------------------------------------------------------------------------------
/qdevices/dynar-simple-lex.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _DYNAR_SIMPLE_LEX_H_
36 | #define _DYNAR_SIMPLE_LEX_H_
37 |
38 | #include "dynar.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | enum dynar_simple_lex_type {
45 | DYNAR_SIMPLE_LEX_TYPE_PLAIN,
46 | DYNAR_SIMPLE_LEX_TYPE_BACKSLASH,
47 | DYNAR_SIMPLE_LEX_TYPE_QUOTE,
48 | };
49 |
50 | struct dynar_simple_lex {
51 | struct dynar token;
52 | struct dynar *input;
53 | enum dynar_simple_lex_type lex_type;
54 | size_t pos;
55 | };
56 |
57 | extern void dynar_simple_lex_init(struct dynar_simple_lex *lex, struct dynar *input,
58 | enum dynar_simple_lex_type lex_type);
59 |
60 | extern void dynar_simple_lex_destroy(struct dynar_simple_lex *lex);
61 |
62 | extern struct dynar *dynar_simple_lex_token_next(struct dynar_simple_lex *lex);
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 |
68 | #endif /* _DYNAR_SIMPLE_LEX_H_ */
69 |
--------------------------------------------------------------------------------
/qdevices/dynar-str.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _DYNAR_STR_H_
36 | #define _DYNAR_STR_H_
37 |
38 | #include
39 |
40 | #include "dynar.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern int dynar_str_cpy(struct dynar *dest, const char *str);
47 |
48 | extern int dynar_str_cat(struct dynar *dest, const char *str);
49 |
50 | extern int dynar_str_catf(struct dynar *dest, const char *format, ...)
51 | __attribute__((__format__(__printf__, 2, 3)));
52 |
53 | extern int dynar_str_vcatf(struct dynar *dest, const char *format, va_list ap)
54 | __attribute__((__format__(__printf__, 2, 0)));
55 |
56 | extern int dynar_str_prepend(struct dynar *dest, const char *str);
57 |
58 | extern int dynar_str_quote_cat(struct dynar *dest, const char *str);
59 |
60 | extern int dynar_str_quote_cpy(struct dynar *dest, const char *str);
61 |
62 | #ifdef __cplusplus
63 | }
64 | #endif
65 |
66 | #endif /* _DYNAR_STR_H_ */
67 |
--------------------------------------------------------------------------------
/qdevices/dynar.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _DYNAR_H_
36 | #define _DYNAR_H_
37 |
38 | #include
39 | #include
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | /*
46 | * Dynamic array structure
47 | */
48 | struct dynar {
49 | char *data;
50 | size_t size;
51 | size_t allocated;
52 | size_t maximum_size;
53 | };
54 |
55 | extern void dynar_init(struct dynar *array, size_t maximum_size);
56 |
57 | extern void dynar_destroy(struct dynar *array);
58 |
59 | extern void dynar_clean(struct dynar *array);
60 |
61 | extern size_t dynar_size(const struct dynar *array);
62 |
63 | extern size_t dynar_max_size(const struct dynar *array);
64 |
65 | extern void dynar_set_max_size(struct dynar *array, size_t maximum_size);
66 |
67 | extern char *dynar_data(const struct dynar *array);
68 |
69 | extern int dynar_cat(struct dynar *array, const void *src, size_t size);
70 |
71 | extern int dynar_prealloc(struct dynar *array, size_t size);
72 |
73 | extern int dynar_prepend(struct dynar *array, const void *src, size_t size);
74 |
75 | extern int dynar_set_size(struct dynar *array, size_t size);
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif /* _DYNAR_H_ */
82 |
--------------------------------------------------------------------------------
/qdevices/log-common.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include "log.h"
36 | #include "log-common.h"
37 | #include "utils.h"
38 |
39 | void
40 | log_common_debug_dump_node_list(const struct node_list *nlist)
41 | {
42 | struct node_list_entry *node_info;
43 | size_t zi;
44 |
45 | log(LOG_DEBUG, " Node list:");
46 |
47 | zi = 0;
48 |
49 | TAILQ_FOREACH(node_info, nlist, entries) {
50 | log(LOG_DEBUG, " %zu node_id = "UTILS_PRI_NODE_ID", "
51 | "data_center_id = "UTILS_PRI_DATACENTER_ID", node_state = %s",
52 | zi, node_info->node_id, node_info->data_center_id,
53 | tlv_node_state_to_str(node_info->node_state));
54 | zi++;
55 | }
56 | }
57 |
58 | void
59 | log_common_msg_decode_error(int ret)
60 | {
61 |
62 | switch (ret) {
63 | case -1:
64 | log(LOG_WARNING, "Received message with option with invalid length");
65 | break;
66 | case -2:
67 | log(LOG_CRIT, "Can't allocate memory");
68 | break;
69 | case -3:
70 | log(LOG_WARNING, "Received inconsistent msg (tlv len > msg size)");
71 | break;
72 | case -4:
73 | log(LOG_WARNING, "Received message with option with invalid value");
74 | break;
75 | default:
76 | log(LOG_ERR, "Unknown error occurred when decoding message");
77 | break;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/qdevices/log-common.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _LOG_COMMON_H_
36 | #define _LOG_COMMON_H_
37 |
38 | #include "node-list.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern void log_common_debug_dump_node_list(const struct node_list *nlist);
45 |
46 | extern void log_common_msg_decode_error(int ret);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif /* _LOG_COMMON_H_ */
53 |
--------------------------------------------------------------------------------
/qdevices/log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _LOG_H_
36 | #define _LOG_H_
37 |
38 | #include
39 | #include
40 | #include
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | #define LOG_TARGET_STDERR 1
47 | #define LOG_TARGET_SYSLOG 2
48 |
49 | #define log(...) log_printf(__VA_ARGS__)
50 | #define log_nss(priority, str) log_printf(priority, "%s (%d): %s", \
51 | str, PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT));
52 |
53 | #define log_err(priority, str) log_printf(priority, "%s (%d): %s", \
54 | str, errno, strerror(errno))
55 |
56 | extern int log_init(const char *ident, int target, int syslog_facility);
57 |
58 | extern void log_printf(int priority, const char *format, ...)
59 | __attribute__((__format__(__printf__, 2, 3)));
60 |
61 | extern void log_vprintf(int priority, const char *format, va_list ap)
62 | __attribute__((__format__(__printf__, 2, 0)));
63 |
64 | extern void log_close(void);
65 |
66 | extern void log_set_debug(int enabled);
67 |
68 | extern void log_set_priority_bump(int enabled);
69 |
70 | extern void log_set_target(int target, int syslog_facility);
71 |
72 | #ifdef __cplusplus
73 | }
74 | #endif
75 |
76 | #endif /* __LOG_H_ */
77 |
--------------------------------------------------------------------------------
/qdevices/msgio.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _MSGIO_H_
36 | #define _MSGIO_H_
37 |
38 | #include
39 |
40 | #include "dynar.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern ssize_t msgio_send(PRFileDesc *sock, const char *msg, size_t msg_len,
47 | size_t *start_pos);
48 |
49 | extern ssize_t msgio_send_blocking(PRFileDesc *sock, const char *msg, size_t msg_len);
50 |
51 | extern int msgio_write(PRFileDesc *sock, const struct dynar *msg, size_t *already_sent_bytes);
52 |
53 | extern int msgio_read(PRFileDesc *sock, struct dynar *msg, size_t *already_received_bytes,
54 | int *skipping_msg);
55 |
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 |
60 | #endif /* _MSGIO_H_ */
61 |
--------------------------------------------------------------------------------
/qdevices/node-list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _NODE_LIST_H_
36 | #define _NODE_LIST_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 |
43 | #include "tlv.h"
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | struct node_list_entry {
50 | uint32_t node_id;
51 | uint32_t data_center_id;
52 | enum tlv_node_state node_state;
53 | TAILQ_ENTRY(node_list_entry) entries;
54 | };
55 |
56 | TAILQ_HEAD(node_list, node_list_entry);
57 |
58 | extern void node_list_init(struct node_list *list);
59 |
60 | extern struct node_list_entry *node_list_add(struct node_list *list,
61 | uint32_t node_id, uint32_t data_center_id, enum tlv_node_state node_state);
62 |
63 | extern struct node_list_entry *node_list_add_from_node_info(
64 | struct node_list *list, const struct tlv_node_info *node_info);
65 |
66 | extern int node_list_clone(struct node_list *dst_list,
67 | const struct node_list *src_list);
68 |
69 | extern void node_list_free(struct node_list *list);
70 |
71 | extern void node_list_del(struct node_list *list,
72 | struct node_list_entry *node);
73 |
74 | extern int node_list_is_empty(const struct node_list *list);
75 |
76 | extern void node_list_entry_to_tlv_node_info(
77 | const struct node_list_entry *node, struct tlv_node_info *node_info);
78 |
79 | extern struct node_list_entry * node_list_find_node_id(const struct node_list *list,
80 | uint32_t node_id);
81 |
82 | extern int node_list_eq(const struct node_list *list1,
83 | const struct node_list *list2);
84 |
85 | extern size_t node_list_size(const struct node_list *nlist);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
91 | #endif /* _NODE_LIST_H_ */
92 |
--------------------------------------------------------------------------------
/qdevices/nss-sock.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _NSS_SOCK_H_
36 | #define _NSS_SOCK_H_
37 |
38 | #include
39 | #include
40 | #include
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | struct nss_sock_non_blocking_client {
47 | char *host_name;
48 | uint16_t port;
49 | PRIntn af;
50 | PRFileDesc *socket;
51 | PRAddrInfo *addr_info;
52 | void *addr_iter;
53 | unsigned int connect_attempts;
54 | int destroyed;
55 | };
56 |
57 | extern int nss_sock_init_nss(char *config_dir);
58 |
59 | extern int nss_sock_check_db_dir(const char *config_dir);
60 |
61 | extern PRFileDesc *nss_sock_create_listen_socket(const char *hostname, uint16_t port,
62 | PRIntn af);
63 |
64 | extern int nss_sock_set_non_blocking(PRFileDesc *sock);
65 |
66 | extern PRFileDesc *nss_sock_create_client_socket(const char *hostname, uint16_t port,
67 | PRIntn af, PRIntervalTime timeout);
68 |
69 | extern PRFileDesc *nss_sock_start_ssl_as_client(PRFileDesc *input_sock, const char *ssl_url,
70 | SSLBadCertHandler bad_cert_hook, SSLGetClientAuthData client_auth_hook,
71 | void *client_auth_hook_arg, int force_handshake, int *reset_would_block);
72 |
73 | extern PRFileDesc *nss_sock_start_ssl_as_server(PRFileDesc *input_sock,
74 | CERTCertificate *server_cert, SECKEYPrivateKey *server_key, int require_client_cert,
75 | int force_handshake, int *reset_would_block);
76 |
77 | extern int nss_sock_non_blocking_client_init(const char *host_name,
78 | uint16_t port, PRIntn af, struct nss_sock_non_blocking_client *client);
79 |
80 | extern int nss_sock_non_blocking_client_try_next(
81 | struct nss_sock_non_blocking_client *client);
82 |
83 | extern void nss_sock_non_blocking_client_destroy(
84 | struct nss_sock_non_blocking_client *client);
85 |
86 | extern int nss_sock_non_blocking_client_succeeded(const PRPollDesc *pfd);
87 |
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #endif /* _NSS_SOCK_H_ */
93 |
--------------------------------------------------------------------------------
/qdevices/pr-poll-array.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _PR_POLL_ARRAY_H_
36 | #define _PR_POLL_ARRAY_H_
37 |
38 | #include
39 | #include
40 |
41 | #include
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | struct pr_poll_array {
48 | PRPollDesc *array;
49 | char *user_data_array;
50 | size_t user_data_size;
51 | ssize_t allocated;
52 | ssize_t items;
53 | };
54 |
55 | extern void pr_poll_array_init(struct pr_poll_array *poll_array, size_t user_data_size);
56 |
57 | extern void pr_poll_array_destroy(struct pr_poll_array *poll_array);
58 |
59 | extern void pr_poll_array_clean(struct pr_poll_array *poll_array);
60 |
61 | extern ssize_t pr_poll_array_size(struct pr_poll_array *poll_array);
62 |
63 | extern ssize_t pr_poll_array_add(struct pr_poll_array *poll_array, PRPollDesc **pfds,
64 | void **user_data);
65 |
66 | extern PRPollDesc *pr_poll_array_get(const struct pr_poll_array *poll_array,
67 | ssize_t pos);
68 |
69 | extern void *pr_poll_array_get_user_data(const struct pr_poll_array *poll_array,
70 | ssize_t pos);
71 |
72 | extern void pr_poll_array_gc(struct pr_poll_array *poll_array);
73 |
74 | #ifdef __cplusplus
75 | }
76 | #endif
77 |
78 | #endif /* _PR_POLL_ARRAY_H_ */
79 |
--------------------------------------------------------------------------------
/qdevices/qdevice-cmap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_CMAP_H_
36 | #define _QDEVICE_CMAP_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 | #include "node-list.h"
43 | #include "qdevice-instance.h"
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | struct qdevice_cmap_change_events {
50 | unsigned int logging : 1;
51 | unsigned int node_list : 1;
52 | unsigned int heuristics : 1;
53 | };
54 |
55 | extern int qdevice_cmap_get_nodelist(cmap_handle_t cmap_handle,
56 | struct node_list *list);
57 |
58 | extern int qdevice_cmap_get_config_version(cmap_handle_t cmap_handle,
59 | uint64_t *config_version);
60 |
61 | extern void qdevice_cmap_init(struct qdevice_instance *instance);
62 |
63 | extern int qdevice_cmap_add_track(struct qdevice_instance *instance);
64 |
65 | extern int qdevice_cmap_del_track(struct qdevice_instance *instance);
66 |
67 | extern void qdevice_cmap_destroy(struct qdevice_instance *instance);
68 |
69 | extern int qdevice_cmap_dispatch(struct qdevice_instance *instance);
70 |
71 | extern int qdevice_cmap_store_config_node_list(struct qdevice_instance *instance);
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
76 |
77 | #endif /* _QDEVICE_CMAP_H_ */
78 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-cmd-str.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_CMD_STR_H_
36 | #define _QDEVICE_HEURISTICS_CMD_STR_H_
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC_LIST_CLEAR "exec-list-clear"
43 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC_LIST_ADD "exec-list-add"
44 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC_LIST_ADD_SPACE \
45 | QDEVICE_HEURISTICS_CMD_STR_EXEC_LIST_ADD " "
46 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC "exec"
47 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC_ADD_SPACE QDEVICE_HEURISTICS_CMD_STR_EXEC " "
48 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC_RESULT "exec-result"
49 | #define QDEVICE_HEURISTICS_CMD_STR_EXEC_RESULT_ADD_SPACE \
50 | QDEVICE_HEURISTICS_CMD_STR_EXEC_RESULT " "
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _QDEVICE_HEURISTICS_CMD_STR_H_ */
57 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-cmd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_CMD_H_
36 | #define _QDEVICE_HEURISTICS_CMD_H_
37 |
38 | #include "qdevice-heuristics-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_heuristics_cmd_write(
45 | struct qdevice_heuristics_instance *instance);
46 |
47 | extern int qdevice_heuristics_cmd_write_exec_list(
48 | struct qdevice_heuristics_instance *instance, const struct qdevice_heuristics_exec_list *new_exec_list);
49 |
50 | extern int qdevice_heuristics_cmd_write_exec(struct qdevice_heuristics_instance *instance,
51 | uint32_t timeout, uint32_t seq_number);
52 |
53 | extern int qdevice_heuristics_cmd_read_from_pipe(
54 | struct qdevice_heuristics_instance *instance);
55 |
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 |
60 | #endif /* _QDEVICE_HEURISTICS_CMD_H_ */
61 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-exec-list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_EXEC_LIST_H_
36 | #define _QDEVICE_HEURISTICS_EXEC_LIST_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | struct qdevice_heuristics_exec_list_entry {
48 | char *name;
49 | char *command;
50 | TAILQ_ENTRY(qdevice_heuristics_exec_list_entry) entries;
51 | };
52 |
53 | TAILQ_HEAD(qdevice_heuristics_exec_list, qdevice_heuristics_exec_list_entry);
54 |
55 | extern void qdevice_heuristics_exec_list_init(
56 | struct qdevice_heuristics_exec_list *list);
57 |
58 | extern struct qdevice_heuristics_exec_list_entry *qdevice_heuristics_exec_list_add(
59 | struct qdevice_heuristics_exec_list *list, char *name, char *command);
60 |
61 | extern void qdevice_heuristics_exec_list_free(
62 | struct qdevice_heuristics_exec_list *list);
63 |
64 | extern size_t qdevice_heuristics_exec_list_size(
65 | const struct qdevice_heuristics_exec_list *list);
66 |
67 | extern int qdevice_heuristics_exec_list_clone(
68 | struct qdevice_heuristics_exec_list *dst_list,
69 | const struct qdevice_heuristics_exec_list *src_list);
70 |
71 | extern void qdevice_heuristics_exec_list_del(
72 | struct qdevice_heuristics_exec_list *list, struct qdevice_heuristics_exec_list_entry *entry);
73 |
74 | extern int qdevice_heuristics_exec_list_is_empty(
75 | const struct qdevice_heuristics_exec_list *list);
76 |
77 | extern struct qdevice_heuristics_exec_list_entry *qdevice_heuristics_exec_list_find_name(
78 | const struct qdevice_heuristics_exec_list *list, const char *name);
79 |
80 | extern int qdevice_heuristics_exec_list_eq(
81 | const struct qdevice_heuristics_exec_list *list1,
82 | const struct qdevice_heuristics_exec_list *list2);
83 |
84 | #ifdef __cplusplus
85 | }
86 | #endif
87 |
88 | #endif /* _QDEVICE_HEURISTICS_EXEC_LIST_H_ */
89 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-exec-result.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include "qdevice-heuristics-exec-result.h"
36 |
37 | const char *
38 | qdevice_heuristics_exec_result_to_str(enum qdevice_heuristics_exec_result exec_result)
39 | {
40 |
41 | switch (exec_result) {
42 | case QDEVICE_HEURISTICS_EXEC_RESULT_FAIL: return ("Fail"); break;
43 | case QDEVICE_HEURISTICS_EXEC_RESULT_PASS: return ("Pass"); break;
44 | case QDEVICE_HEURISTICS_EXEC_RESULT_DISABLED: return ("Disabled"); break;
45 | }
46 |
47 | return ("Unknown heuristics exec result value");
48 | }
49 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-exec-result.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_EXEC_RESULT_H_
36 | #define _QDEVICE_HEURISTICS_EXEC_RESULT_H_
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | enum qdevice_heuristics_exec_result {
43 | /*
44 | * Heuristics worker received command to exec heuristics but list is empty. This
45 | * is happening when heuristics is disabled.
46 | */
47 | QDEVICE_HEURISTICS_EXEC_RESULT_DISABLED = 0,
48 | /*
49 | * All executed commands passed
50 | */
51 | QDEVICE_HEURISTICS_EXEC_RESULT_PASS = 1,
52 | /*
53 | * One (or more) commands failed or timed-out
54 | */
55 | QDEVICE_HEURISTICS_EXEC_RESULT_FAIL = 2,
56 | };
57 |
58 | extern const char * qdevice_heuristics_exec_result_to_str(
59 | enum qdevice_heuristics_exec_result exec_result);
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 |
65 | #endif /* _QDEVICE_HEURISTICS_EXEC_RESULT_H_ */
66 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-instance.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 |
37 | #include "qdevice-heuristics-instance.h"
38 | #include "qdevice-heuristics-exec-list.h"
39 |
40 | int
41 | qdevice_heuristics_instance_init(struct qdevice_heuristics_instance *instance)
42 | {
43 |
44 | memset(instance, 0, sizeof(*instance));
45 |
46 | qdevice_heuristics_exec_list_init(&instance->exec_list);
47 | qdevice_heuristics_result_notifier_list_init(&instance->exec_result_notifier_list);
48 |
49 | return (0);
50 | }
51 |
52 | int
53 | qdevice_heuristics_instance_destroy(struct qdevice_heuristics_instance *instance)
54 | {
55 |
56 | qdevice_heuristics_result_notifier_list_free(&instance->exec_result_notifier_list);
57 | qdevice_heuristics_exec_list_free(&instance->exec_list);
58 |
59 | return (0);
60 | }
61 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-instance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_INSTANCE_H_
36 | #define _QDEVICE_HEURISTICS_INSTANCE_H_
37 |
38 | #include "dynar.h"
39 | #include "send-buffer-list.h"
40 | #include "qdevice-heuristics-mode.h"
41 | #include "qdevice-heuristics-exec-list.h"
42 | #include "qdevice-heuristics-exec-result.h"
43 | #include "qdevice-heuristics-result-notifier.h"
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | struct qdevice_heuristics_instance {
50 | int pipe_cmd_send;
51 | int pipe_cmd_recv;
52 | int pipe_log_recv;
53 | pid_t worker_pid;
54 | struct send_buffer_list cmd_out_buffer_list;
55 | struct dynar log_in_buffer;
56 | struct dynar cmd_in_buffer;
57 |
58 | uint32_t timeout;
59 | uint32_t sync_timeout;
60 | uint32_t interval;
61 |
62 | enum qdevice_heuristics_mode mode;
63 |
64 | int waiting_for_result;
65 | uint32_t expected_reply_seq_number;
66 |
67 | struct qdevice_heuristics_exec_list exec_list;
68 |
69 | struct qdevice_heuristics_result_notifier_list exec_result_notifier_list;
70 | };
71 |
72 | extern int qdevice_heuristics_instance_init(struct qdevice_heuristics_instance *instance);
73 |
74 | extern int qdevice_heuristics_instance_destroy(struct qdevice_heuristics_instance *instance);
75 |
76 | #ifdef __cplusplus
77 | }
78 | #endif
79 |
80 | #endif /* _QDEVICE_HEURISTICS_INSTANCE_H_ */
81 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-io.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_IO_H_
36 | #define _QDEVICE_HEURISTICS_IO_H_
37 |
38 | #include "dynar.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern ssize_t qdevice_heuristics_io_blocking_write(int fd, const void *buf,
45 | size_t count);
46 |
47 | extern int qdevice_heuristics_io_read(int fd, struct dynar *dest);
48 |
49 | extern int qdevice_heuristics_io_write(int fd, const struct dynar *msg,
50 | size_t *already_sent_bytes);
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _QDEVICE_HEURISTICS_IO_H_ */
57 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_LOG_H_
36 | #define _QDEVICE_HEURISTICS_LOG_H_
37 |
38 | #include "qdevice-heuristics-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_heuristics_log_read_from_pipe(
45 | struct qdevice_heuristics_instance *instance);
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* _QDEVICE_HEURISTICS_LOG_H_ */
52 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-mode.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 | #include
37 | #include
38 |
39 | #include "qdevice-heuristics-mode.h"
40 |
41 | const char*
42 | qdevice_heuristics_mode_to_str(enum qdevice_heuristics_mode mode)
43 | {
44 | switch (mode) {
45 | case QDEVICE_HEURISTICS_MODE_DISABLED: return ("Disabled"); break;
46 | case QDEVICE_HEURISTICS_MODE_ENABLED: return ("Enabled"); break;
47 | case QDEVICE_HEURISTICS_MODE_SYNC: return ("Enabled only on sync"); break;
48 | }
49 |
50 | return ("Undefined");
51 | }
52 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-mode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_MODE_H_
36 | #define _QDEVICE_HEURISTICS_MODE_H_
37 |
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | enum qdevice_heuristics_mode {
44 | QDEVICE_HEURISTICS_MODE_DISABLED = 0,
45 | QDEVICE_HEURISTICS_MODE_ENABLED = 1,
46 | QDEVICE_HEURISTICS_MODE_SYNC = 2,
47 | };
48 |
49 | extern const char *qdevice_heuristics_mode_to_str(enum qdevice_heuristics_mode mode);
50 |
51 | #ifdef __cplusplus
52 | }
53 | #endif
54 |
55 | #endif /* _QDEVICE_HEURISTICS_MODE_H_ */
56 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-worker-cmd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_WORKER_CMD_H_
36 | #define _QDEVICE_HEURISTICS_WORKER_CMD_H_
37 |
38 | #include "qdevice-heuristics-worker-instance.h"
39 | #include "qdevice-heuristics-exec-result.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern int qdevice_heuristics_worker_cmd_read_from_pipe(
46 | struct qdevice_heuristics_worker_instance *instance);
47 |
48 | extern int qdevice_heuristics_worker_cmd_write_exec_result(
49 | struct qdevice_heuristics_worker_instance *instance, uint32_t seq_number,
50 | enum qdevice_heuristics_exec_result exec_result);
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _QDEVICE_HEURISTICS_WORKER_CMD_H_ */
57 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-worker-instance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_WORKER_INSTANCE_H_
36 | #define _QDEVICE_HEURISTICS_WORKER_INSTANCE_H_
37 |
38 | #include "dynar.h"
39 |
40 | #include "qdevice-heuristics-exec-list.h"
41 | #include "process-list.h"
42 | #include "timer-list.h"
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | struct qdevice_heuristics_worker_instance {
49 | struct dynar cmd_in_buffer;
50 | struct dynar cmd_out_buffer;
51 | struct dynar log_out_buffer;
52 |
53 | struct qdevice_heuristics_exec_list exec_list;
54 | struct process_list main_process_list;
55 | struct timer_list main_timer_list;
56 |
57 | struct timer_list_entry *kill_list_timer;
58 | struct timer_list_entry *exec_timeout_timer;
59 |
60 | uint32_t last_exec_seq_number;
61 |
62 | int schedule_exit;
63 | };
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | #endif /* _QDEVICE_HEURISTICS_WORKER_INSTANCE_H_ */
70 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-worker-log.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 | #include
37 | #include
38 |
39 | #include "dynar.h"
40 | #include "dynar-str.h"
41 | #include "qdevice-heuristics-io.h"
42 | #include "qdevice-heuristics-worker.h"
43 | #include "qdevice-heuristics-worker-log.h"
44 |
45 | static int
46 | qdevice_heuristics_worker_log_remove_newlines(struct dynar *str)
47 | {
48 | size_t len;
49 | size_t zi;
50 | char *buf;
51 |
52 | len = dynar_size(str);
53 | buf = dynar_data(str);
54 |
55 | for (zi = 0; zi < len ; zi++) {
56 | if (buf[zi] == '\n' || buf[zi] == '\r') {
57 | buf[zi] = ' ';
58 | }
59 | }
60 |
61 | return (0);
62 | }
63 |
64 | void
65 | qdevice_heuristics_worker_log_printf(struct qdevice_heuristics_worker_instance *instance,
66 | int priority, const char *format, ...)
67 | {
68 | va_list ap;
69 | va_list ap_copy;
70 |
71 | va_start(ap, format);
72 |
73 | if (dynar_str_cpy(&instance->log_out_buffer, "") != -1 &&
74 | dynar_str_catf(&instance->log_out_buffer, "%u ", priority) != -1 &&
75 | dynar_str_vcatf(&instance->log_out_buffer, format, ap) != -1 &&
76 | qdevice_heuristics_worker_log_remove_newlines(&instance->log_out_buffer) != -1 &&
77 | dynar_str_cat(&instance->log_out_buffer, "\n") != -1) {
78 | /*
79 | * It was possible to log everything
80 | */
81 | (void)qdevice_heuristics_io_blocking_write(QDEVICE_HEURISTICS_WORKER_LOG_OUT_FD,
82 | dynar_data(&instance->log_out_buffer), dynar_size(&instance->log_out_buffer));
83 | } else {
84 | /*
85 | * As a fallback try to log to syslog
86 | */
87 | va_copy(ap_copy, ap);
88 | openlog("qdevice_heuristics_worker", LOG_PID, LOG_DAEMON);
89 | syslog(LOG_ERR, "Log entry sent to syslog instead of parent process");
90 | vsyslog(priority, format, ap_copy);
91 | closelog();
92 | va_end(ap_copy);
93 | }
94 |
95 | va_end(ap);
96 | }
97 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-worker-log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_WORKER_LOG_H_
36 | #define _QDEVICE_HEURISTICS_WORKER_LOG_H_
37 |
38 | #include
39 |
40 | #include "qdevice-heuristics-worker-instance.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern void qdevice_heuristics_worker_log_printf(
47 | struct qdevice_heuristics_worker_instance *instance,
48 | int priority, const char *format, ...) __attribute__((__format__(__printf__, 3, 0)));
49 |
50 | #ifdef __cplusplus
51 | }
52 | #endif
53 |
54 | #endif /* _QDEVICE_HEURISTICS_WORKER_LOG_H_ */
55 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics-worker.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_WORKER_H_
36 | #define _QDEVICE_HEURISTICS_WORKER_H_
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | #define QDEVICE_HEURISTICS_WORKER_CMD_IN_FD 0
43 | #define QDEVICE_HEURISTICS_WORKER_CMD_OUT_FD 1
44 | #define QDEVICE_HEURISTICS_WORKER_LOG_OUT_FD 2
45 |
46 | void qdevice_heuristics_worker_start(size_t ipc_max_send_receive_size,
47 | int use_execvp, size_t max_processes, uint32_t kill_list_interval);
48 |
49 | int qdevice_heuristics_worker_exec_timeout_timer_callback(void *data1, void *data2);
50 |
51 | #ifdef __cplusplus
52 | }
53 | #endif
54 |
55 | #endif /* _QDEVICE_HEURISTICS_WORKER_H_ */
56 |
--------------------------------------------------------------------------------
/qdevices/qdevice-heuristics.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_HEURISTICS_H_
36 | #define _QDEVICE_HEURISTICS_H_
37 |
38 | #include "dynar.h"
39 | #include "qdevice-advanced-settings.h"
40 | #include "send-buffer-list.h"
41 | #include "qdevice-heuristics-instance.h"
42 | #include "qdevice-heuristics-log.h"
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | extern void qdevice_heuristics_init(struct qdevice_heuristics_instance *instance,
49 | struct qdevice_advanced_settings *advanced_settings);
50 |
51 | extern void qdevice_heuristics_destroy(struct qdevice_heuristics_instance *instance,
52 | int wait_for_worker_exit);
53 |
54 | extern int qdevice_heuristics_exec(struct qdevice_heuristics_instance *instance,
55 | int sync_in_progress);
56 |
57 | extern int qdevice_heuristics_waiting_for_result(
58 | const struct qdevice_heuristics_instance *instance);
59 |
60 | extern int qdevice_heuristics_change_exec_list(
61 | struct qdevice_heuristics_instance *instance,
62 | const struct qdevice_heuristics_exec_list *new_exec_list, int sync_in_progress);
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 |
68 | #endif /* _QDEVICE_HEURISTICS_H_ */
69 |
--------------------------------------------------------------------------------
/qdevices/qdevice-ipc-cmd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_IPC_CMD_H_
36 | #define _QDEVICE_IPC_CMD_H_
37 |
38 | #include "dynar.h"
39 | #include "qdevice-instance.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern int qdevice_ipc_cmd_status(struct qdevice_instance *instance, struct dynar *outbuf,
46 | int verbose);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif /* _QDEVICE_IPC_CMD_H_ */
53 |
--------------------------------------------------------------------------------
/qdevices/qdevice-ipc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_IPC_H_
36 | #define _QDEVICE_IPC_H_
37 |
38 | #include "qdevice-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | struct qdevice_ipc_user_data {
45 | int shutdown_requested;
46 | };
47 |
48 | extern int qdevice_ipc_init(struct qdevice_instance *instance);
49 |
50 | extern int qdevice_ipc_close(struct qdevice_instance *instance);
51 |
52 | extern int qdevice_ipc_destroy(struct qdevice_instance *instance);
53 |
54 | extern int qdevice_ipc_accept(struct qdevice_instance *instance,
55 | struct unix_socket_client **res_client);
56 |
57 | extern void qdevice_ipc_client_disconnect(struct qdevice_instance *instance,
58 | struct unix_socket_client *client);
59 |
60 | extern void qdevice_ipc_io_read(struct qdevice_instance *instance,
61 | struct unix_socket_client *client);
62 |
63 | extern void qdevice_ipc_io_write(struct qdevice_instance *instance,
64 | struct unix_socket_client *client);
65 |
66 | extern int qdevice_ipc_send_error(struct qdevice_instance *instance,
67 | struct unix_socket_client *client, const char *error_fmt, ...)
68 | __attribute__((__format__(__printf__, 3, 4)));
69 |
70 | extern int qdevice_ipc_send_buffer(struct qdevice_instance *instance,
71 | struct unix_socket_client *client);
72 |
73 | extern int qdevice_ipc_is_closed(struct qdevice_instance *instance);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif /* _QDEVICE_IPC_H_ */
80 |
--------------------------------------------------------------------------------
/qdevices/qdevice-log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_LOG_H_
36 | #define _QDEVICE_LOG_H_
37 |
38 | #include "qdevice-instance.h"
39 | #include "log.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern int qdevice_log_init(struct qdevice_instance *instance, int foreground,
46 | int force_debug, int bump_log_priority);
47 |
48 | extern void qdevice_log_configure(struct qdevice_instance *instance);
49 |
50 | extern void qdevice_log_close(struct qdevice_instance *instance);
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _QDEVICE_LOG_H_ */
57 |
--------------------------------------------------------------------------------
/qdevices/qdevice-model-type.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_MODEL_TYPE_H_
36 | #define _QDEVICE_MODEL_TYPE_H_
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | enum qdevice_model_type {
43 | QDEVICE_MODEL_TYPE_NET = 0,
44 | QDEVICE_MODEL_TYPE_ARRAY_SIZE,
45 | };
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* _QDEVICE_MODEL_TYPE_H_ */
52 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-cast-vote-timer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_CAST_VOTE_TIMER_H_
36 | #define _QDEVICE_NET_CAST_VOTE_TIMER_H_
37 |
38 | #include "qdevice-net-instance.h"
39 | #include "tlv.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern int qdevice_net_cast_vote_timer_update(
46 | struct qdevice_net_instance *instance, enum tlv_vote vote);
47 |
48 | extern void qdevice_net_cast_vote_timer_set_paused(
49 | struct qdevice_net_instance *instance, int paused);
50 |
51 | #ifdef __cplusplus
52 | }
53 | #endif
54 |
55 | #endif /* _QDEVICE_NET_CAST_VOTE_TIMER_H_ */
56 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-echo-request-timer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_ECHO_REQUEST_TIMER_H_
36 | #define _QDEVICE_NET_ECHO_REQUEST_TIMER_H_
37 |
38 | #include "qdevice-net-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_net_echo_request_timer_schedule(struct qdevice_net_instance *instance);
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
49 |
50 | #endif /* _QDEVICE_NET_ECHO_REQUEST_TIMER_H_ */
51 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-heuristics.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_HEURISTICS_H_
36 | #define _QDEVICE_NET_HEURISTICS_H_
37 |
38 | #include "qdevice-heuristics-exec-result.h"
39 | #include "qdevice-net-instance.h"
40 | #include "tlv.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern enum tlv_heuristics qdevice_net_heuristics_exec_result_to_tlv(
47 | enum qdevice_heuristics_exec_result exec_result);
48 |
49 | extern int qdevice_net_heuristics_stop_timer(struct qdevice_net_instance *net_instance);
50 |
51 | extern int qdevice_net_heuristics_schedule_timer(struct qdevice_net_instance *net_instance);
52 |
53 | extern int qdevice_net_heuristics_init(struct qdevice_net_instance *net_instance);
54 |
55 | extern int qdevice_net_heuristics_exec_after_connect(struct qdevice_net_instance *net_instance);
56 |
57 | #ifdef __cplusplus
58 | }
59 | #endif
60 |
61 | #endif /* _QDEVICE_NET_HEURISTICS_H_ */
62 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-ipc-cmd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_IPC_CMD_H_
36 | #define _QDEVICE_NET_IPC_CMD_H_
37 |
38 | #include "dynar.h"
39 | #include "qdevice-net-instance.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern int qdevice_net_ipc_cmd_status(struct qdevice_net_instance *instance,
46 | struct dynar *outbuf, int verbose);
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif /* _QDEVICE_NET_IPC_CMD_H_ */
53 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-msg-received.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_MSG_RECEIVED_H_
36 | #define _QDEVICE_NET_MSG_RECEIVED_H_
37 |
38 | #include "qdevice-net-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_net_msg_received(struct qdevice_net_instance *instance);
45 |
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* _QDEVICE_NET_MSG_RECEIVED_H_ */
52 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-nss.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2019 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 | #include
37 |
38 | #include "log.h"
39 | #include "qdevice-net-nss.h"
40 | #include "qdevice-net-instance.h"
41 | #include "qnet-config.h"
42 |
43 | SECStatus
44 | qdevice_net_nss_bad_cert_hook(void *arg, PRFileDesc *fd) {
45 | if (PR_GetError() == SEC_ERROR_EXPIRED_CERTIFICATE ||
46 | PR_GetError() == SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE ||
47 | PR_GetError() == SEC_ERROR_CRL_EXPIRED ||
48 | PR_GetError() == SEC_ERROR_KRL_EXPIRED ||
49 | PR_GetError() == SSL_ERROR_EXPIRED_CERT_ALERT) {
50 | log(LOG_WARNING, "Server certificate is expired.");
51 |
52 | return (SECSuccess);
53 | }
54 |
55 | log_nss(LOG_ERR, "Server certificate verification failure.");
56 |
57 | return (SECFailure);
58 | }
59 |
60 | SECStatus
61 | qdevice_net_nss_get_client_auth_data(void *arg, PRFileDesc *sock, struct CERTDistNamesStr *caNames,
62 | struct CERTCertificateStr **pRetCert, struct SECKEYPrivateKeyStr **pRetKey)
63 | {
64 | struct qdevice_net_instance *instance;
65 |
66 | log(LOG_DEBUG, "Sending client auth data.");
67 |
68 | instance = (struct qdevice_net_instance *)arg;
69 |
70 | instance->tls_client_cert_sent = 1;
71 |
72 | return (NSS_GetClientAuthData((void *)instance->advanced_settings->net_nss_client_cert_nickname,
73 | sock, caNames, pRetCert, pRetKey));
74 | }
75 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-nss.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_NSS_H_
36 | #define _QDEVICE_NET_NSS_H_
37 |
38 | #include
39 | #include
40 | #include
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern SECStatus qdevice_net_nss_bad_cert_hook(void *arg, PRFileDesc *fd);
47 |
48 | extern SECStatus qdevice_net_nss_get_client_auth_data(void *arg,
49 | PRFileDesc *sock, struct CERTDistNamesStr *caNames,
50 | struct CERTCertificateStr **pRetCert, struct SECKEYPrivateKeyStr **pRetKey);
51 |
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif /* _QDEVICE_NET_NSS_H_ */
58 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-send.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_SEND_H_
36 | #define _QDEVICE_NET_SEND_H_
37 |
38 | #include
39 |
40 | #include "qdevice-net-instance.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern int qdevice_net_send_echo_request(struct qdevice_net_instance *instance);
47 |
48 | extern int qdevice_net_send_preinit(struct qdevice_net_instance *instance);
49 |
50 | extern int qdevice_net_send_init(struct qdevice_net_instance *instance);
51 |
52 | extern int qdevice_net_send_ask_for_vote(struct qdevice_net_instance *instance);
53 |
54 | extern int qdevice_net_send_config_node_list(struct qdevice_net_instance *instance,
55 | const struct node_list *nlist, int config_version_set, uint64_t config_version,
56 | int initial);
57 |
58 | extern int qdevice_net_send_heuristics_change(struct qdevice_net_instance *instance,
59 | enum tlv_heuristics heuristics);
60 |
61 | extern int qdevice_net_send_membership_node_list(
62 | struct qdevice_net_instance *instance, const struct tlv_ring_id *ring_id,
63 | uint32_t node_list_entries, uint32_t node_list[], enum tlv_heuristics heuristics);
64 |
65 | extern int qdevice_net_send_quorum_node_list(
66 | struct qdevice_net_instance *instance, enum tlv_quorate quorate,
67 | uint32_t node_list_entries, votequorum_node_t node_list[]);
68 |
69 | extern int qdevice_net_send_set_option(struct qdevice_net_instance *instance,
70 | int add_heartbeat_interval, uint32_t heartbeat_interval,
71 | int add_keep_active_partition_tie_breaker,
72 | enum tlv_keep_active_partition_tie_breaker keep_active_partition_tie_breaker);
73 |
74 | #ifdef __cplusplus
75 | }
76 | #endif
77 |
78 | #endif /* _QDEVICE_NET_SEND_H_ */
79 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-socket.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_SOCKET_H_
36 | #define _QDEVICE_NET_SOCKET_H_
37 |
38 | #include "qdevice-net-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_net_socket_read(struct qdevice_net_instance *instance);
45 |
46 | extern int qdevice_net_socket_write(struct qdevice_net_instance *instance);
47 |
48 | extern int qdevice_net_socket_add_to_main_poll_loop(struct qdevice_net_instance *instance);
49 |
50 | extern int qdevice_net_socket_del_from_main_poll_loop(struct qdevice_net_instance *instance);
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _QDEVICE_NET_SOCKET_H_ */
57 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-votequorum.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include "log.h"
36 | #include "qdevice-net-votequorum.h"
37 |
38 | enum tlv_node_state
39 | qdevice_net_votequorum_node_state_to_tlv(uint32_t votequorum_node_state)
40 | {
41 | enum tlv_node_state res;
42 |
43 | switch (votequorum_node_state) {
44 | case VOTEQUORUM_NODESTATE_MEMBER: res = TLV_NODE_STATE_MEMBER; break;
45 | case VOTEQUORUM_NODESTATE_DEAD: res = TLV_NODE_STATE_DEAD; break;
46 | case VOTEQUORUM_NODESTATE_LEAVING: res = TLV_NODE_STATE_LEAVING; break;
47 | default:
48 | log(LOG_ERR, "qdevice_net_votequorum_node_state_to_tlv: Unhandled votequorum "
49 | "node state %"PRIu32, votequorum_node_state);
50 | exit(EXIT_FAILURE);
51 | break;
52 | }
53 |
54 | return (res);
55 | }
56 |
57 | void
58 | qdevice_net_votequorum_ring_id_to_tlv(struct tlv_ring_id *tlv_rid,
59 | const votequorum_ring_id_t *votequorum_rid)
60 | {
61 |
62 | tlv_rid->node_id = votequorum_rid->nodeid;
63 | tlv_rid->seq = votequorum_rid->seq;
64 | }
65 |
--------------------------------------------------------------------------------
/qdevices/qdevice-net-votequorum.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_NET_VOTEQUORUM_H_
36 | #define _QDEVICE_NET_VOTEQUORUM_H_
37 |
38 | #include
39 |
40 | #include "qdevice-net-instance.h"
41 | #include "tlv.h"
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | extern enum tlv_node_state qdevice_net_votequorum_node_state_to_tlv(
48 | uint32_t votequorum_node_state);
49 |
50 | extern void qdevice_net_votequorum_ring_id_to_tlv(struct tlv_ring_id *tlv_rid,
51 | const votequorum_ring_id_t *votequorum_rid);
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif /* _QDEVICE_NET_VOTEQUORUM_H_ */
58 |
--------------------------------------------------------------------------------
/qdevices/qdevice-pr-poll-loop-cb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_PR_POLL_LOOP_CB_H_
36 | #define _QDEVICE_PR_POLL_LOOP_CB_H_
37 |
38 | #include "qdevice-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_pr_poll_loop_cb_register(struct qdevice_instance *instance);
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
49 |
50 | #endif /* _QDEVICE_PR_POLL_LOOP_CB_H_ */
51 |
--------------------------------------------------------------------------------
/qdevices/qdevice-pr-poll-loop.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include "log.h"
36 | #include "qdevice-pr-poll-loop.h"
37 | #include "timer-list.h"
38 |
39 | static int
40 | wait_for_initial_heuristics_exec_result_timeout_timer_cb(void *data1, void *data2)
41 | {
42 | int *timeout_called = (int *)data1;
43 |
44 | *timeout_called = 1;
45 |
46 | return (0);
47 | }
48 |
49 | int
50 | qdevice_pr_poll_loop_wait_for_initial_heuristics_exec_result(struct qdevice_instance *instance)
51 | {
52 | struct timer_list_entry *timeout_timer;
53 | int timeout_called;
54 | int poll_res;
55 | PRUint32 timeout;
56 |
57 | timeout_called = 0;
58 |
59 | /*
60 | * We know this is never larger than QDEVICE_DEFAULT_HEURISTICS_MAX_TIMEOUT * 2
61 | */
62 | timeout = (PRUint32)instance->heuristics_instance.sync_timeout * 2;
63 |
64 | timeout_timer = timer_list_add(pr_poll_loop_get_timer_list(&instance->main_poll_loop),
65 | timeout, wait_for_initial_heuristics_exec_result_timeout_timer_cb,
66 | &timeout_called, NULL);
67 |
68 | while ((poll_res = pr_poll_loop_exec(&instance->main_poll_loop)) == 0 &&
69 | !instance->vq_node_list_initial_heuristics_finished &&
70 | !timeout_called) {
71 | }
72 |
73 | if (poll_res == -2) {
74 | log(LOG_CRIT, "Initial heuristics exec result poll failed - internal error");
75 | return (-1);
76 | } else if (poll_res == -3) {
77 | log_nss(LOG_CRIT, "Initial heuristics exec result poll failed - PR_Poll error");
78 | return (-1);
79 | }
80 |
81 | if (timeout_called) {
82 | log(LOG_ERR, "Timeout waiting for initial heuristics exec result");
83 | return (-1);
84 | }
85 |
86 | timer_list_entry_delete(pr_poll_loop_get_timer_list(&instance->main_poll_loop), timeout_timer);
87 |
88 | return (poll_res);
89 | }
90 |
--------------------------------------------------------------------------------
/qdevices/qdevice-pr-poll-loop.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_PR_POLL_LOOP_H_
36 | #define _QDEVICE_PR_POLL_LOOP_H_
37 |
38 | #include "qdevice-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qdevice_pr_poll_loop_wait_for_initial_heuristics_exec_result(
45 | struct qdevice_instance *instance);
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* _QDEVICE_PR_POLL_LOOP_H_ */
52 |
--------------------------------------------------------------------------------
/qdevices/qdevice-votequorum.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QDEVICE_VOTEQUORUM_H_
36 | #define _QDEVICE_VOTEQUORUM_H_
37 |
38 | #include
39 |
40 | #include "qdevice-instance.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern void qdevice_votequorum_init(struct qdevice_instance *instance);
47 |
48 | extern void qdevice_votequorum_destroy(struct qdevice_instance *instance);
49 |
50 | extern int qdevice_votequorum_dispatch(struct qdevice_instance *instance);
51 |
52 | extern int qdevice_votequorum_poll(struct qdevice_instance *instance,
53 | int cast_vote);
54 |
55 | extern int qdevice_votequorum_wait_for_ring_id(
56 | struct qdevice_instance *instance);
57 |
58 | extern int qdevice_votequorum_master_wins(struct qdevice_instance *instance,
59 | int allow);
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 |
65 | #endif /* _QDEVICE_VOTEQUORUM_H_ */
66 |
--------------------------------------------------------------------------------
/qdevices/qnetd-advanced-settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_ADVANCED_SETTINGS_H_
36 | #define _QNETD_ADVANCED_SETTINGS_H_
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | struct qnetd_advanced_settings {
43 | int listen_backlog;
44 | size_t max_client_send_buffers;
45 | size_t max_client_send_size;
46 | size_t max_client_receive_size;
47 | char *nss_db_dir;
48 | char *cert_nickname;
49 | uint32_t heartbeat_interval_min;
50 | uint32_t heartbeat_interval_max;
51 | uint8_t dpd_enabled;
52 | char *lock_file;
53 | char *local_socket_file;
54 | int local_socket_backlog;
55 | size_t ipc_max_clients;
56 | size_t ipc_max_send_size;
57 | size_t ipc_max_receive_size;
58 | enum tlv_keep_active_partition_tie_breaker keep_active_partition_tie_breaker;
59 | double dpd_interval_coefficient;
60 | };
61 |
62 | extern int qnetd_advanced_settings_init(struct qnetd_advanced_settings *settings);
63 |
64 | extern int qnetd_advanced_settings_set(struct qnetd_advanced_settings *settings,
65 | const char *option, const char *value);
66 |
67 | extern void qnetd_advanced_settings_destroy(struct qnetd_advanced_settings *settings);
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif /* _QNETD_ADVANCED_SETTINGS_H_ */
74 |
--------------------------------------------------------------------------------
/qdevices/qnetd-algo-utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Christine Caulfield (ccaulfie@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_ALGO_UTILS_H_
36 | #define _QNETD_ALGO_UTILS_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | struct qnetd_algo_partition {
48 | struct tlv_ring_id ring_id;
49 | int num_nodes;
50 | int score;
51 | TAILQ_ENTRY(qnetd_algo_partition) entries;
52 | };
53 |
54 | typedef TAILQ_HEAD(, qnetd_algo_partition) partitions_list_t;
55 |
56 | extern int qnetd_algo_all_ring_ids_match(struct qnetd_client *client,
57 | const struct tlv_ring_id *ring_id);
58 |
59 | extern struct qnetd_algo_partition *qnetd_algo_find_partition(partitions_list_t *partitions,
60 | const struct tlv_ring_id *ring_id);
61 |
62 | extern int qnetd_algo_create_partitions(struct qnetd_client *client,
63 | partitions_list_t *partitions, const struct tlv_ring_id *ring_id);
64 |
65 | extern void qnetd_algo_free_partitions(partitions_list_t *partitions);
66 |
67 | extern void qnetd_algo_dump_partitions(partitions_list_t *partitions);
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif /* _QNETD_ALGO_UTILS_H_ */
74 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-algo-timer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLIENT_ALGO_TIMER_H_
36 | #define _QNETD_CLIENT_ALGO_TIMER_H_
37 |
38 | #include "qnetd-client.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qnetd_client_algo_timer_is_scheduled(struct qnetd_client *client);
45 |
46 | extern int qnetd_client_algo_timer_schedule_timeout(struct qnetd_client *client,
47 | uint32_t timeout);
48 |
49 | extern int qnetd_client_algo_timer_schedule(struct qnetd_client *client);
50 |
51 | extern int qnetd_client_algo_timer_abort(struct qnetd_client *client);
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif /* _QNETD_CLIENT_ALGO_TIMER_H_ */
58 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-dpd-timer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLIENT_DPD_TIMER_H_
36 | #define _QNETD_CLIENT_DPD_TIMER_H_
37 |
38 | #include "qnetd-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qnetd_client_dpd_timer_init(struct qnetd_instance *instance,
45 | struct qnetd_client *client);
46 |
47 | extern void qnetd_client_dpd_timer_destroy(struct qnetd_instance *instance,
48 | struct qnetd_client *client);
49 |
50 | extern void qnetd_client_dpd_timer_reschedule(struct qnetd_instance *instance,
51 | struct qnetd_client *client);
52 |
53 | extern int qnetd_client_dpd_timer_update_interval(struct qnetd_instance *instance,
54 | struct qnetd_client *client);
55 |
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 |
60 | #endif /* _QNETD_CLIENT_DPD_TIMER_H_ */
61 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-list.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 | #include
37 |
38 | #include
39 | #include
40 | #include
41 |
42 | #include "qnetd-client-list.h"
43 |
44 | void
45 | qnetd_client_list_init(struct qnetd_client_list *client_list)
46 | {
47 |
48 | TAILQ_INIT(client_list);
49 | }
50 |
51 | struct qnetd_client *
52 | qnetd_client_list_add(struct qnetd_client_list *client_list, PRFileDesc *sock, PRNetAddr *addr,
53 | char *addr_str,
54 | size_t max_receive_size, size_t max_send_buffers, size_t max_send_size,
55 | struct timer_list *main_timer_list)
56 | {
57 | struct qnetd_client *client;
58 |
59 | client = (struct qnetd_client *)malloc(sizeof(*client));
60 | if (client == NULL) {
61 | return (NULL);
62 | }
63 |
64 | qnetd_client_init(client, sock, addr, addr_str, max_receive_size, max_send_buffers,
65 | max_send_size, main_timer_list);
66 |
67 | TAILQ_INSERT_TAIL(client_list, client, entries);
68 |
69 | return (client);
70 | }
71 |
72 | void
73 | qnetd_client_list_free(struct qnetd_client_list *client_list)
74 | {
75 | struct qnetd_client *client;
76 | struct qnetd_client *client_next;
77 |
78 | client = TAILQ_FIRST(client_list);
79 |
80 | while (client != NULL) {
81 | client_next = TAILQ_NEXT(client, entries);
82 |
83 | qnetd_client_destroy(client);
84 | free(client);
85 |
86 | client = client_next;
87 | }
88 |
89 | TAILQ_INIT(client_list);
90 | }
91 |
92 | void
93 | qnetd_client_list_del(struct qnetd_client_list *client_list, struct qnetd_client *client)
94 | {
95 |
96 | TAILQ_REMOVE(client_list, client, entries);
97 |
98 | qnetd_client_destroy(client);
99 | free(client);
100 | }
101 |
102 | size_t
103 | qnetd_client_list_no_clients(struct qnetd_client_list *client_list)
104 | {
105 | size_t res;
106 | struct qnetd_client *client;
107 |
108 | res = 0;
109 |
110 | TAILQ_FOREACH(client, client_list, entries) {
111 | res++;
112 | }
113 |
114 | return (res);
115 | }
116 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLIENT_LIST_H_
36 | #define _QNETD_CLIENT_LIST_H_
37 |
38 | #include
39 | #include
40 |
41 | #include "qnetd-client.h"
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | TAILQ_HEAD(qnetd_client_list, qnetd_client);
48 |
49 | extern void qnetd_client_list_init(struct qnetd_client_list *client_list);
50 |
51 | extern struct qnetd_client *qnetd_client_list_add(struct qnetd_client_list *client_list,
52 | PRFileDesc *sock, PRNetAddr *addr, char *addr_str, size_t max_receive_size,
53 | size_t max_send_buffers, size_t max_send_size, struct timer_list *main_timer_list);
54 |
55 | extern void qnetd_client_list_free(struct qnetd_client_list *client_list);
56 |
57 | extern void qnetd_client_list_del(struct qnetd_client_list *client_list,
58 | struct qnetd_client *client);
59 |
60 | extern size_t qnetd_client_list_no_clients(
61 | struct qnetd_client_list *client_list);
62 |
63 | #ifdef __cplusplus
64 | }
65 | #endif
66 |
67 | #endif /* _QNETD_CLIENT_LIST_H_ */
68 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-msg-received.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLIENT_MSG_RECEIVED_H_
36 | #define _QNETD_CLIENT_MSG_RECEIVED_H_
37 |
38 | #include
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | extern int qnetd_client_msg_received(struct qnetd_instance *instance,
45 | struct qnetd_client *client);
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* _QNETD_CLIENT_MSG_RECEIVED_H_ */
52 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-net.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLIENT_NET_H_
36 | #define _QNETD_CLIENT_NET_H_
37 |
38 | #include
39 |
40 | #include "qnetd-client.h"
41 | #include "qnetd-instance.h"
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | extern int qnetd_client_net_write(struct qnetd_instance *instance,
48 | struct qnetd_client *client);
49 |
50 | extern int qnetd_client_net_read(struct qnetd_instance *instance,
51 | struct qnetd_client *client);
52 |
53 | extern int qnetd_client_net_accept(struct qnetd_instance *instance);
54 |
55 | #ifdef __cplusplus
56 | }
57 | #endif
58 |
59 | #endif /* _QNETD_CLIENT_NET_H_ */
60 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client-send.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLIENT_SEND_H_
36 | #define _QNETD_CLIENT_SEND_H_
37 |
38 | #include
39 |
40 | #include "qnetd-client.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern int qnetd_client_send_err(struct qnetd_client *client,
47 | int add_msg_seq_number, uint32_t msg_seq_number, enum tlv_reply_error_code reply);
48 |
49 | extern int qnetd_client_send_vote_info(struct qnetd_client *client,
50 | uint32_t msg_seq_number, const struct tlv_ring_id *ring_id, enum tlv_vote vote);
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _QNETD_CLIENT_SEND_H_ */
57 |
--------------------------------------------------------------------------------
/qdevices/qnetd-client.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 |
37 | #include
38 |
39 | #include "qnet-config.h"
40 | #include "qnetd-client.h"
41 |
42 | void
43 | qnetd_client_init(struct qnetd_client *client, PRFileDesc *sock, PRNetAddr *addr,
44 | char *addr_str,
45 | size_t max_receive_size, size_t max_send_buffers, size_t max_send_size,
46 | struct timer_list *main_timer_list)
47 | {
48 |
49 | memset(client, 0, sizeof(*client));
50 | client->socket = sock;
51 | client->addr_str = addr_str;
52 | memcpy(&client->addr, addr, sizeof(*addr));
53 | dynar_init(&client->receive_buffer, max_receive_size);
54 | send_buffer_list_init(&client->send_buffer_list, max_send_buffers, max_send_size);
55 | node_list_init(&client->configuration_node_list);
56 | node_list_init(&client->last_membership_node_list);
57 | node_list_init(&client->last_quorum_node_list);
58 | client->main_timer_list = main_timer_list;
59 | /*
60 | * Set max heartbeat interval before client sends init msg
61 | */
62 | client->heartbeat_interval = QNETD_DEFAULT_HEARTBEAT_INTERVAL_MAX;
63 | }
64 |
65 | void
66 | qnetd_client_destroy(struct qnetd_client *client)
67 | {
68 |
69 | free(client->cluster_name);
70 | free(client->addr_str);
71 | node_list_free(&client->last_quorum_node_list);
72 | node_list_free(&client->last_membership_node_list);
73 | node_list_free(&client->configuration_node_list);
74 | send_buffer_list_free(&client->send_buffer_list);
75 | dynar_destroy(&client->receive_buffer);
76 | }
77 |
--------------------------------------------------------------------------------
/qdevices/qnetd-cluster-list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLUSTER_LIST_H_
36 | #define _QNETD_CLUSTER_LIST_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 |
43 | #include "qnetd-client-list.h"
44 | #include "qnetd-cluster.h"
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | TAILQ_HEAD(qnetd_cluster_list, qnetd_cluster);
51 |
52 | extern void qnetd_cluster_list_init(struct qnetd_cluster_list *list);
53 |
54 | extern struct qnetd_cluster *qnetd_cluster_list_find_by_name(
55 | struct qnetd_cluster_list *list, const char *cluster_name, size_t cluster_name_len);
56 |
57 | extern struct qnetd_cluster *qnetd_cluster_list_add_client(
58 | struct qnetd_cluster_list *list, struct qnetd_client *client);
59 |
60 | extern void qnetd_cluster_list_del_client(
61 | struct qnetd_cluster_list *list, struct qnetd_cluster *cluster, struct qnetd_client *client);
62 |
63 | extern void qnetd_cluster_list_free(struct qnetd_cluster_list *list);
64 |
65 | extern size_t qnetd_cluster_list_size(
66 | const struct qnetd_cluster_list *list);
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif /* _QNETD_CLUSTER_LIST_H_ */
73 |
--------------------------------------------------------------------------------
/qdevices/qnetd-cluster.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 | #include
37 | #include
38 |
39 | #include "qnetd-cluster.h"
40 |
41 | int
42 | qnetd_cluster_init(struct qnetd_cluster *cluster, const char *cluster_name, size_t cluster_name_len)
43 | {
44 |
45 | memset(cluster, 0, sizeof(*cluster));
46 |
47 | cluster->cluster_name = malloc(cluster_name_len + 1);
48 | if (cluster->cluster_name == NULL) {
49 | return (-1);
50 | }
51 | memset(cluster->cluster_name, 0, cluster_name_len + 1);
52 | memcpy(cluster->cluster_name, cluster_name, cluster_name_len);
53 |
54 | cluster->cluster_name_len = cluster_name_len;
55 | TAILQ_INIT(&cluster->client_list);
56 |
57 | return (0);
58 | }
59 |
60 | void
61 | qnetd_cluster_destroy(struct qnetd_cluster *cluster)
62 | {
63 |
64 | free(cluster->cluster_name);
65 | cluster->cluster_name = NULL;
66 | }
67 |
68 | size_t
69 | qnetd_cluster_size(const struct qnetd_cluster *cluster)
70 | {
71 | size_t res;
72 | struct qnetd_client *client;
73 |
74 | res = 0;
75 |
76 | TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
77 | res++;
78 | }
79 |
80 | return (res);
81 | }
82 |
83 | struct qnetd_client *
84 | qnetd_cluster_find_client_by_node_id(const struct qnetd_cluster *cluster, uint32_t node_id)
85 | {
86 | struct qnetd_client *client;
87 |
88 | TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
89 | if (client->node_id == node_id) {
90 | return (client);
91 | }
92 | }
93 |
94 | return (NULL);
95 | }
96 |
--------------------------------------------------------------------------------
/qdevices/qnetd-cluster.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_CLUSTER_H_
36 | #define _QNETD_CLUSTER_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 |
43 | #include "tlv.h"
44 | #include "qnetd-client-list.h"
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | struct qnetd_cluster {
51 | char *cluster_name;
52 | size_t cluster_name_len;
53 | void *algorithm_data;
54 | struct qnetd_client_list client_list;
55 | TAILQ_ENTRY(qnetd_cluster) entries;
56 | };
57 |
58 | extern int qnetd_cluster_init(struct qnetd_cluster *cluster,
59 | const char *cluster_name, size_t cluster_name_len);
60 |
61 | extern void qnetd_cluster_destroy(struct qnetd_cluster *cluster);
62 |
63 | extern size_t qnetd_cluster_size(const struct qnetd_cluster *cluster);
64 |
65 | extern struct qnetd_client *qnetd_cluster_find_client_by_node_id(
66 | const struct qnetd_cluster *cluster, uint32_t node_id);
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif /* _QNETD_CLUSTER_H_ */
73 |
--------------------------------------------------------------------------------
/qdevices/qnetd-instance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_INSTANCE_H_
36 | #define _QNETD_INSTANCE_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 | #include
43 |
44 | #include "qnetd-client-list.h"
45 | #include "qnetd-cluster-list.h"
46 | #include "pr-poll-array.h"
47 | #include "qnet-config.h"
48 | #include "unix-socket-ipc.h"
49 | #include "qnetd-advanced-settings.h"
50 | #include "pr-poll-loop.h"
51 | #include "timer-list.h"
52 |
53 | #ifdef __cplusplus
54 | extern "C" {
55 | #endif
56 |
57 | struct qnetd_instance {
58 | struct {
59 | PRFileDesc *socket;
60 | CERTCertificate *cert;
61 | SECKEYPrivateKey *private_key;
62 | } server;
63 | size_t max_clients;
64 | struct qnetd_client_list clients;
65 | struct qnetd_cluster_list clusters;
66 | enum tlv_tls_supported tls_supported;
67 | int tls_client_cert_required;
68 | const char *host_addr;
69 | uint16_t host_port;
70 | struct unix_socket_ipc local_ipc;
71 | const struct qnetd_advanced_settings *advanced_settings;
72 | struct pr_poll_loop main_poll_loop;
73 | };
74 |
75 | extern int qnetd_instance_init(struct qnetd_instance *instance,
76 | enum tlv_tls_supported tls_supported, int tls_client_cert_required, size_t max_clients,
77 | const struct qnetd_advanced_settings *advanced_settings);
78 |
79 | extern int qnetd_instance_destroy(struct qnetd_instance *instance);
80 |
81 | extern void qnetd_instance_client_disconnect(struct qnetd_instance *instance,
82 | struct qnetd_client *client, int server_going_down);
83 |
84 | extern int qnetd_instance_init_certs(struct qnetd_instance *instance);
85 |
86 | #ifdef __cplusplus
87 | }
88 | #endif
89 |
90 | #endif /* _QNETD_INSTANCE_H_ */
91 |
--------------------------------------------------------------------------------
/qdevices/qnetd-ipc-cmd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_IPC_CMD_H_
36 | #define _QNETD_IPC_CMD_H_
37 |
38 | #include "dynar.h"
39 | #include "qnetd-instance.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern int qnetd_ipc_cmd_status(struct qnetd_instance *instance,
46 | struct dynar *outbuf, int verbose);
47 |
48 | extern int qnetd_ipc_cmd_list(struct qnetd_instance *instance,
49 | struct dynar *outbuf, int verbose, const char *cluster_name);
50 |
51 | #ifdef __cplusplus
52 | }
53 | #endif
54 |
55 | #endif /* _QNETD_IPC_CMD_H_ */
56 |
--------------------------------------------------------------------------------
/qdevices/qnetd-ipc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_IPC_H_
36 | #define _QNETD_IPC_H_
37 |
38 | #include "qnetd-instance.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | struct qnetd_ipc_user_data {
45 | int shutdown_requested;
46 | };
47 |
48 | extern int qnetd_ipc_init(struct qnetd_instance *instance);
49 |
50 | extern int qnetd_ipc_close(struct qnetd_instance *instance);
51 |
52 | extern int qnetd_ipc_is_closed(struct qnetd_instance *instance);
53 |
54 | extern int qnetd_ipc_destroy(struct qnetd_instance *instance);
55 |
56 | extern int qnetd_ipc_accept(struct qnetd_instance *instance,
57 | struct unix_socket_client **res_client);
58 |
59 | extern void qnetd_ipc_client_disconnect(struct qnetd_instance *instance,
60 | struct unix_socket_client *client);
61 |
62 | extern void qnetd_ipc_io_read(struct qnetd_instance *instance,
63 | struct unix_socket_client *client);
64 |
65 | extern void qnetd_ipc_io_write(struct qnetd_instance *instance,
66 | struct unix_socket_client *client);
67 |
68 | extern int qnetd_ipc_send_error(struct qnetd_instance *instance,
69 | struct unix_socket_client *client, const char *error_fmt, ...)
70 | __attribute__((__format__(__printf__, 3, 4)));
71 |
72 | extern int qnetd_ipc_send_buffer(struct qnetd_instance *instance,
73 | struct unix_socket_client *client);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif /* _QNETD_IPC_H_ */
80 |
--------------------------------------------------------------------------------
/qdevices/qnetd-log-debug.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2017 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _QNETD_LOG_DEBUG_H_
36 | #define _QNETD_LOG_DEBUG_H_
37 |
38 | #include "qnetd-client.h"
39 | #include "qnetd-cluster-list.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | extern void qnetd_log_debug_dump_cluster(struct qnetd_cluster *cluster);
46 |
47 | extern void qnetd_log_debug_new_client_connected(struct qnetd_client *client);
48 |
49 | extern void qnetd_log_debug_config_node_list_received(struct qnetd_client *client,
50 | uint32_t msg_seq_num, int config_version_set, uint64_t config_version,
51 | const struct node_list *nodes, int initial);
52 |
53 | extern void qnetd_log_debug_membership_node_list_received(struct qnetd_client *client,
54 | uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
55 | enum tlv_heuristics heuristics, const struct node_list *nodes);
56 |
57 | extern void qnetd_log_debug_quorum_node_list_received(struct qnetd_client *client,
58 | uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes);
59 |
60 | extern void qnetd_log_debug_client_disconnect(struct qnetd_client *client,
61 | int server_going_down);
62 |
63 | extern void qnetd_log_debug_ask_for_vote_received(struct qnetd_client *client,
64 | uint32_t msg_seq_num);
65 |
66 | extern void qnetd_log_debug_vote_info_reply_received(struct qnetd_client *client,
67 | uint32_t msg_seq_num);
68 |
69 | extern void qnetd_log_debug_send_vote_info(struct qnetd_client *client,
70 | uint32_t msg_seq_num, enum tlv_vote vote);
71 |
72 | extern void qnetd_log_debug_heuristics_change_received(struct qnetd_client *client,
73 | uint32_t msg_seq_num, enum tlv_heuristics heuristics);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif /* _QNETD_LOG_DEBUG_H_ */
80 |
--------------------------------------------------------------------------------
/qdevices/send-buffer-list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _SEND_BUFFER_LIST_H_
36 | #define _SEND_BUFFER_LIST_H_
37 |
38 | #include
39 |
40 | #include "dynar.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | struct send_buffer_list_entry {
47 | struct dynar buffer;
48 | size_t msg_already_sent_bytes;
49 |
50 | TAILQ_ENTRY(send_buffer_list_entry) entries;
51 | };
52 |
53 | struct send_buffer_list {
54 | size_t max_list_entries;
55 | size_t allocated_list_entries;
56 |
57 | size_t max_buffer_size;
58 |
59 | TAILQ_HEAD(, send_buffer_list_entry) list;
60 | TAILQ_HEAD(, send_buffer_list_entry) free_list;
61 | };
62 |
63 | extern void send_buffer_list_init(struct send_buffer_list *sblist,
64 | size_t max_list_entries, size_t max_buffer_size);
65 |
66 | extern struct send_buffer_list_entry *send_buffer_list_get_new(struct send_buffer_list *sblist);
67 |
68 | extern void send_buffer_list_put(struct send_buffer_list *sblist,
69 | struct send_buffer_list_entry *sblist_entry);
70 |
71 | extern void send_buffer_list_discard_new(
72 | struct send_buffer_list *sblist, struct send_buffer_list_entry *sblist_entry);
73 |
74 | extern struct send_buffer_list_entry *send_buffer_list_get_active(
75 | const struct send_buffer_list *sblist);
76 |
77 | extern void send_buffer_list_delete(struct send_buffer_list *sblist,
78 | struct send_buffer_list_entry *sblist_entry);
79 |
80 | extern int send_buffer_list_empty(
81 | const struct send_buffer_list *sblist);
82 |
83 | extern void send_buffer_list_free(struct send_buffer_list *sblist);
84 |
85 | extern void send_buffer_list_set_max_buffer_size(
86 | struct send_buffer_list *sblist, size_t max_buffer_size);
87 |
88 | extern void send_buffer_list_set_max_list_entries(
89 | struct send_buffer_list *sblist, size_t max_list_entries);
90 |
91 | #ifdef __cplusplus
92 | }
93 | #endif
94 |
95 | #endif /* _SEND_BUFFER_LIST_H_ */
96 |
--------------------------------------------------------------------------------
/qdevices/unix-socket-client-list.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 | #include
37 |
38 | #include "unix-socket-client-list.h"
39 |
40 | void
41 | unix_socket_client_list_init(struct unix_socket_client_list *client_list)
42 | {
43 |
44 | TAILQ_INIT(client_list);
45 | }
46 |
47 | struct unix_socket_client *
48 | unix_socket_client_list_add(struct unix_socket_client_list *client_list,
49 | int sock, size_t max_receive_size, size_t max_send_size, void *user_data)
50 | {
51 | struct unix_socket_client *client;
52 |
53 | client = (struct unix_socket_client *)malloc(sizeof(*client));
54 | if (client == NULL) {
55 | return (NULL);
56 | }
57 |
58 | unix_socket_client_init(client, sock, max_receive_size, max_send_size, user_data);
59 |
60 | TAILQ_INSERT_TAIL(client_list, client, entries);
61 |
62 | return (client);
63 | }
64 |
65 | void
66 | unix_socket_client_list_free(struct unix_socket_client_list *client_list)
67 | {
68 | struct unix_socket_client *client;
69 | struct unix_socket_client *client_next;
70 |
71 | client = TAILQ_FIRST(client_list);
72 |
73 | while (client != NULL) {
74 | client_next = TAILQ_NEXT(client, entries);
75 |
76 | unix_socket_client_destroy(client);
77 | free(client);
78 |
79 | client = client_next;
80 | }
81 |
82 | TAILQ_INIT(client_list);
83 | }
84 |
85 | void
86 | unix_socket_client_list_del(struct unix_socket_client_list *client_list,
87 | struct unix_socket_client *client)
88 | {
89 |
90 | TAILQ_REMOVE(client_list, client, entries);
91 | unix_socket_client_destroy(client);
92 | free(client);
93 | }
94 |
95 | size_t
96 | unix_socket_client_list_no_clients(struct unix_socket_client_list *client_list)
97 | {
98 | size_t res;
99 | struct unix_socket_client *client;
100 |
101 | res = 0;
102 |
103 | TAILQ_FOREACH(client, client_list, entries) {
104 | res++;
105 | }
106 |
107 | return (res);
108 | }
109 |
--------------------------------------------------------------------------------
/qdevices/unix-socket-client-list.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _UNIX_SOCKET_CLIENT_LIST_H_
36 | #define _UNIX_SOCKET_CLIENT_LIST_H_
37 |
38 | #include
39 | #include
40 |
41 | #include "unix-socket-client.h"
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | TAILQ_HEAD(unix_socket_client_list, unix_socket_client);
48 |
49 | extern void unix_socket_client_list_init(
50 | struct unix_socket_client_list *client_list);
51 |
52 | extern struct unix_socket_client *unix_socket_client_list_add(
53 | struct unix_socket_client_list *client_list,
54 | int sock, size_t max_receive_size, size_t max_send_size, void *user_data);
55 |
56 | extern void unix_socket_client_list_free(
57 | struct unix_socket_client_list *client_list);
58 |
59 | extern void unix_socket_client_list_del(
60 | struct unix_socket_client_list *client_list, struct unix_socket_client *client);
61 |
62 | extern size_t unix_socket_client_list_no_clients(
63 | struct unix_socket_client_list *client_list);
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | #endif /* _UNIX_SOCKET_CLIENT_LIST_H_ */
70 |
--------------------------------------------------------------------------------
/qdevices/unix-socket-client.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _UNIX_SOCKET_CLIENT_H_
36 | #define _UNIX_SOCKET_CLIENT_H_
37 |
38 | #include
39 |
40 | #include
41 | #include
42 |
43 | #include "dynar.h"
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | struct unix_socket_client {
50 | int socket;
51 | struct dynar receive_buffer;
52 | struct dynar send_buffer;
53 | size_t msg_already_received_bytes;
54 | size_t msg_already_sent_bytes;
55 | int reading_line;
56 | int writing_buffer;
57 | int schedule_disconnect;
58 | void *user_data;
59 | TAILQ_ENTRY(unix_socket_client) entries;
60 | };
61 |
62 | extern void unix_socket_client_init(struct unix_socket_client *client, int sock,
63 | size_t max_receive_size, size_t max_send_size, void *user_data);
64 |
65 | extern void unix_socket_client_destroy(struct unix_socket_client *client);
66 |
67 | extern void unix_socket_client_read_line(struct unix_socket_client *client, int enabled);
68 |
69 | extern void unix_socket_client_write_buffer(struct unix_socket_client *client, int enabled);
70 |
71 | extern int unix_socket_client_io_read(struct unix_socket_client *client);
72 |
73 | extern int unix_socket_client_io_write(struct unix_socket_client *client);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif /* _UNIX_SOCKET_CLIENT_H_ */
80 |
--------------------------------------------------------------------------------
/qdevices/unix-socket-ipc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _UNIX_SOCKET_IPC_H_
36 | #define _UNIX_SOCKET_IPC_H_
37 |
38 | #include "unix-socket-client.h"
39 | #include "unix-socket-client-list.h"
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | struct unix_socket_ipc {
46 | int socket;
47 | int backlog;
48 | char *socket_file_name;
49 | struct unix_socket_client_list clients;
50 | size_t max_clients;
51 | size_t max_receive_size;
52 | size_t max_send_size;
53 | };
54 |
55 | extern int unix_socket_ipc_init(struct unix_socket_ipc *ipc,
56 | const char *socket_file_name, int backlog, size_t max_clients, size_t max_receive_size,
57 | size_t max_send_size);
58 |
59 | extern int unix_socket_ipc_destroy(struct unix_socket_ipc *ipc);
60 |
61 | extern int unix_socket_ipc_accept(struct unix_socket_ipc *ipc,
62 | struct unix_socket_client **res_client);
63 |
64 | void unix_socket_ipc_client_disconnect(struct unix_socket_ipc *ipc,
65 | struct unix_socket_client *client);
66 |
67 | extern int unix_socket_ipc_close(struct unix_socket_ipc *ipc);
68 |
69 | extern int unix_socket_ipc_is_closed(struct unix_socket_ipc *ipc);
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 |
75 | #endif /* _UNIX_SOCKET_IPC_H_ */
76 |
--------------------------------------------------------------------------------
/qdevices/unix-socket.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _UNIX_SOCKET_H_
36 | #define _UNIX_SOCKET_H_
37 |
38 | #include
39 | #include
40 | #include
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | extern int unix_socket_server_create(const char *path, int non_blocking, int backlog);
47 |
48 | extern int unix_socket_client_create(const char *path, int non_blocking);
49 |
50 | extern int unix_socket_server_destroy(int sock, const char *path);
51 |
52 | extern int unix_socket_server_accept(int sock, int non_blocking);
53 |
54 | extern int unix_socket_close(int sock);
55 |
56 | extern ssize_t unix_socket_read(int sock, void *buf, size_t len);
57 |
58 | extern ssize_t unix_socket_write(int sock, void *buf, size_t len);
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 |
64 | #endif /* _UNIX_SOCKET_H_ */
65 |
--------------------------------------------------------------------------------
/qdevices/utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2020 Red Hat, Inc.
3 | *
4 | * All rights reserved.
5 | *
6 | * Author: Jan Friesse (jfriesse@redhat.com)
7 | *
8 | * This software licensed under BSD license, the text of which follows:
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * - Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * - Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * - Neither the name of the Red Hat, Inc. nor the names of its
19 | * contributors may be used to endorse or promote products derived from this
20 | * software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 | * THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _UTILS_H_
36 | #define _UTILS_H_
37 |
38 | #include
39 | #include
40 |
41 | #define UTILS_PRI_NODE_ID "%" PRIu32
42 | #define UTILS_PRI_DATACENTER_ID "%" PRIu32
43 | /*
44 | #define UTILS_PRI_NODE_ID "0x%" PRIx32
45 | #define UTILS_PRI_DATACENTER_ID "0x%" PRIx32
46 | */
47 | #define UTILS_PRI_MSG_SEQ "%" PRIu32
48 | #define UTILS_PRI_RING_ID "%" PRIx32 ".%" PRIx64
49 | #define UTILS_PRI_CONFIG_VERSION "%" PRIu64
50 | #define UTILS_PRI_EXPECTED_VOTES "%" PRIu32
51 |
52 | #ifdef __cplusplus
53 | extern "C" {
54 | #endif
55 |
56 | extern int utils_parse_bool_str(const char *str);
57 |
58 | extern int utils_flock(const char *lockfile, pid_t pid,
59 | int *another_instance_running);
60 |
61 | extern void utils_tty_detach(void);
62 |
63 | extern int utils_fd_set_non_blocking(int fd);
64 |
65 | extern int utils_strtonum(const char *str, long long int min_val,
66 | long long int max_val, long long int *res);
67 |
68 | extern int utils_strtod(const char *str, double min_val, double max_val,
69 | double *res);
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 |
75 | #endif /* _UTILS_H_ */
76 |
--------------------------------------------------------------------------------