| 1 | /***** |
| 2 | * |
| 3 | * Copyright (C) 2008-2020 CS GROUP - France. All Rights Reserved. |
| 4 | * Author: Yoann Vandoorselaere <[email protected]> |
| 5 | * |
| 6 | * This file is part of the Prelude library. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Lesser General Public License as published by |
| 10 | * the Free Software Foundation; either version 2.1, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | *****/ |
| 23 | |
| 24 | #include <list> |
| 25 | |
| 26 | #include "prelude.h"cxx . . $ `<file>/src/include/prelude.h`/ |
| 27 | #include "prelude-connection-pool.h"cxx . . $ `<file>/src/include/prelude-connection-pool.h`/ |
| 28 | |
| 29 | #include "prelude-connection-pool.hxx"cxx . . $ `<file>/bindings/c++/include/prelude-connection-pool.hxx`/ |
| 30 | #include "prelude-client.hxx"cxx . . $ `<file>/bindings/c++/include/prelude-client.hxx`/ |
| 31 | #include "prelude-error.hxx"cxx . . $ `<file>/bindings/c++/include/prelude-error.hxx`/ |
| 32 | |
| 33 | using namespace Prelude; |
| 34 | |
| 35 | |
| 36 | Connectioncxx . . $ Prelude/Connection#::~cxx . . $ Prelude/Connection#`~Connection`(ced63f7c635d850d).Connectioncxx . . $ Prelude/Connection#() |
| 37 | { |
| 38 | if ( _concxx . . $ Prelude/Connection#_con. ) |
| 39 | prelude_connection_destroy(_concxx . . $ Prelude/Connection#_con.); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | Connectioncxx . . $ Prelude/Connection#::Connectioncxx . . $ Prelude/Connection#Connection(49f6e7a06ebc5aa8).() |
| 44 | { |
| 45 | _concxx . . $ Prelude/Connection#_con. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | Connectioncxx . . $ Prelude/Connection#::Connectioncxx . . $ Prelude/Connection#Connection(e46d4c5b0276fb92).(const Connectioncxx . . $ Prelude/Connection# &con) |
| 50 | { |
| 51 | _concxx . . $ Prelude/Connection#_con. = (con._concxx . . $ Prelude/Connection#_con.) ? prelude_connection_ref(con._concxx . . $ Prelude/Connection#_con.) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | Connectioncxx . . $ Prelude/Connection#::Connectioncxx . . $ Prelude/Connection#Connection(85c52e162fed56f9).(const char *addr) |
| 56 | { |
| 57 | int ret; |
| 58 | |
| 59 | ret = prelude_connection_new(&_concxx . . $ Prelude/Connection#_con., addr); |
| 60 | if ( ret < 0 ) |
| 61 | throw PreludeErrorcxx . . $ Prelude/PreludeError#(ret); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | Connectioncxx . . $ Prelude/Connection#::Connectioncxx . . $ Prelude/Connection#Connection(633eddce2f4e68f6).(prelude_connection_t *con, bool own_data) |
| 66 | { |
| 67 | _concxx . . $ Prelude/Connection#_con. = con; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | prelude_connection_t *Connectioncxx . . $ Prelude/Connection#::getConnectioncxx . . $ Prelude/Connection#getConnection(17bba4a52849f6b0).() const |
| 72 | { |
| 73 | return _concxx . . $ Prelude/Connection#_con.; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | void Connectioncxx . . $ Prelude/Connection#::closecxx . . $ Prelude/Connection#close(49f6e7a06ebc5aa8).() |
| 78 | { |
| 79 | prelude_connection_close(_concxx . . $ Prelude/Connection#_con.); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | void Connectioncxx . . $ Prelude/Connection#::connectcxx . . $ Prelude/Connection#connect(8d5876fbdb3a8991).(ClientProfilecxx . . $ Prelude/ClientProfile# &cp, int permission) |
| 84 | { |
| 85 | int ret; |
| 86 | |
| 87 | ret = prelude_connection_connect(_concxx . . $ Prelude/Connection#_con., cp, (prelude_connection_permission_t) permission); |
| 88 | if ( ret < 0 ) |
| 89 | throw PreludeErrorcxx . . $ Prelude/PreludeError#(ret); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | void Connectioncxx . . $ Prelude/Connection#::setStatecxx . . $ Prelude/Connection#setState(d4f767463ce0a6b3).(int state) |
| 94 | { |
| 95 | prelude_connection_set_state(_concxx . . $ Prelude/Connection#_con., (prelude_connection_state_t) state); |
| 96 | } |
| 97 | |
| 98 | |
| 99 | int Connectioncxx . . $ Prelude/Connection#::getStatecxx . . $ Prelude/Connection#getState(455f465bc33b4cdf).() const |
| 100 | { |
| 101 | return prelude_connection_get_state(_concxx . . $ Prelude/Connection#_con.); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | void Connectioncxx . . $ Prelude/Connection#::setDatacxx . . $ Prelude/Connection#setData(5d22bdacc48458e8).(void *data) |
| 106 | { |
| 107 | prelude_connection_set_data(_concxx . . $ Prelude/Connection#_con., data); |
| 108 | } |
| 109 | |
| 110 | |
| 111 | void *Connectioncxx . . $ Prelude/Connection#::getDatacxx . . $ Prelude/Connection#getData(45a5c5ac6be858a8).() const |
| 112 | { |
| 113 | return prelude_connection_get_data(_concxx . . $ Prelude/Connection#_con.); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | int Connectioncxx . . $ Prelude/Connection#::getPermissioncxx . . $ Prelude/Connection#getPermission(455f465bc33b4cdf).() const |
| 118 | { |
| 119 | return prelude_connection_get_permission(_concxx . . $ Prelude/Connection#_con.); |
| 120 | } |
| 121 | |
| 122 | |
| 123 | void Connectioncxx . . $ Prelude/Connection#::setPeerAnalyzeridcxx . . $ Prelude/Connection#setPeerAnalyzerid(2c44cd906ae4e829).(uint64_t analyzerid) |
| 124 | { |
| 125 | prelude_connection_set_peer_analyzerid(_concxx . . $ Prelude/Connection#_con., analyzerid); |
| 126 | } |
| 127 | |
| 128 | |
| 129 | uint64_t Connectioncxx . . $ Prelude/Connection#::getPeerAnalyzeridcxx . . $ Prelude/Connection#getPeerAnalyzerid(fe4d2d262d4164a8).() const |
| 130 | { |
| 131 | return prelude_connection_get_peer_analyzerid(_concxx . . $ Prelude/Connection#_con.); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | const char *Connectioncxx . . $ Prelude/Connection#::getLocalAddrcxx . . $ Prelude/Connection#getLocalAddr(a9f41ea0e82d88cf).() const |
| 136 | { |
| 137 | return prelude_connection_get_local_addr(_concxx . . $ Prelude/Connection#_con.); |
| 138 | } |
| 139 | |
| 140 | |
| 141 | unsigned int Connectioncxx . . $ Prelude/Connection#::getLocalPortcxx . . $ Prelude/Connection#getLocalPort(ddd8539a2fcdd4ce).() const |
| 142 | { |
| 143 | return prelude_connection_get_local_port(_concxx . . $ Prelude/Connection#_con.); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | const char *Connectioncxx . . $ Prelude/Connection#::getPeerAddrcxx . . $ Prelude/Connection#getPeerAddr(a9f41ea0e82d88cf).() const |
| 148 | { |
| 149 | return prelude_connection_get_peer_addr(_concxx . . $ Prelude/Connection#_con.); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | unsigned int Connectioncxx . . $ Prelude/Connection#::getPeerPortcxx . . $ Prelude/Connection#getPeerPort(ddd8539a2fcdd4ce).() const |
| 154 | { |
| 155 | return prelude_connection_get_peer_port(_concxx . . $ Prelude/Connection#_con.); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | int Connectioncxx . . $ Prelude/Connection#::getFdcxx . . $ Prelude/Connection#getFd(455f465bc33b4cdf).() const |
| 160 | { |
| 161 | return prelude_io_get_fd(prelude_connection_get_fd(_concxx . . $ Prelude/Connection#_con.)); |
| 162 | } |
| 163 | |
| 164 | |
| 165 | Preludecxx . . $ Prelude/::IDMEFcxx . . $ Prelude/IDMEF# Connectioncxx . . $ Prelude/Connection#::recvIDMEFcxx . . $ Prelude/Connection#recvIDMEF(12a115ee0e175284).() |
| 166 | { |
| 167 | int ret; |
| 168 | idmef_message_t *idmef; |
| 169 | |
| 170 | ret = prelude_connection_recv_idmef(_concxx . . $ Prelude/Connection#_con., &idmef); |
| 171 | if ( ret < 0 ) |
| 172 | throw PreludeErrorcxx . . $ Prelude/PreludeError#(ret); |
| 173 | |
| 174 | return IDMEFcxx . . $ Prelude/IDMEF#IDMEF(5b736bc7e1bf22c4).((idmef_object_t *) idmef); |
| 175 | } |
| 176 | |
| 177 | |
| 178 | bool Connectioncxx . . $ Prelude/Connection#::isAlivecxx . . $ Prelude/Connection#isAlive(50ce9a9e25b4a850).() const |
| 179 | { |
| 180 | return prelude_connection_is_alive(_concxx . . $ Prelude/Connection#_con.); |
| 181 | } |
| 182 | |
| 183 | Connectioncxx . . $ Prelude/Connection# &Connectioncxx . . $ Prelude/Connection#::operatorcxx . . $ Prelude/Connection#`operator=`(a9a016ce29cf54c0).=(const Connectioncxx . . $ Prelude/Connection# &con) |
| 184 | { |
| 185 | if ( this != &con && _concxx . . $ Prelude/Connection#_con. != con._concxx . . $ Prelude/Connection#_con. ) { |
| 186 | if ( _concxx . . $ Prelude/Connection#_con. ) |
| 187 | prelude_connection_destroy(_concxx . . $ Prelude/Connection#_con.); |
| 188 | |
| 189 | _concxx . . $ Prelude/Connection#_con. = (con._concxx . . $ Prelude/Connection#_con.) ? prelude_connection_ref(con._concxx . . $ Prelude/Connection#_con.) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 190 | } |
| 191 | |
| 192 | return *this; |
| 193 | } |
| 194 | |
| 195 | |
| 196 | Connectioncxx . . $ Prelude/Connection#::operatorcxx . . $ Prelude/Connection#`operator prelude_connection *`(db96fcf48178c59b). prelude_connection_t *() |
| 197 | { |
| 198 | return _concxx . . $ Prelude/Connection#_con.; |
| 199 | } |