2 * Copyright (c) 2014 Alexander Golovko <alexandro@onsec.ru>
4 * Portions (c) 2015 Matthias Bethke <matthias@towiski.de>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __NSCANG_CLIENT_H
30 #define __NSCANG_CLIENT_H
32 #include <openssl/ssl.h>
33 #include <openssl/err.h>
37 typedef enum { NSCANG_STATE_NONE
=0, NSCANG_STATE_NEW
, NSCANG_STATE_MOIN
} nscang_state_t
;
38 typedef enum { NSCANG_RESP_MOIN
=1, NSCANG_RESP_OKAY
} nscang_response_t
;
40 NSCANG_ERROR_MALLOC
=1,
42 NSCANG_ERROR_TOO_LONG_RESPONSE
,
43 NSCANG_ERROR_BAD_PROTO_VERSION
,
44 NSCANG_ERROR_PROTOCOL_MISMATCH
,
45 NSCANG_ERROR_UNKNOWN_RESPONSE
,
48 NSCANG_ERROR_BAD_STATE
,
49 NSCANG_ERROR_SSL_CTX_CREATE
=101,
50 NSCANG_ERROR_SSL_CIPHERS
,
51 NSCANG_ERROR_SSL_BIO_CREATE
,
52 NSCANG_ERROR_SSL_CREATE
,
65 nscang_error_t _errno
;
71 int nscang_client_init(nscang_client_t
*c
, char *host
, int port
,
72 char *ciphers
, char *identity
, char *psk
);
73 void nscang_client_free(nscang_client_t
*c
);
74 void nscang_client_disconnect(nscang_client_t
*c
);
75 int nscang_client_send_moin(nscang_client_t
*c
, int timeout
);
76 int nscang_client_send_command(nscang_client_t
*c
, const char *command
, int timeout
);
77 int nscang_client_send_push(nscang_client_t
*c
, char *host
, char *service
,
78 int status
, char *message
, int timeout
);
79 int nscang_client_send_quit(nscang_client_t
*c
);
80 char *nscang_client_errstr(nscang_client_t
*c
, char *buf
, int buf_size
);
82 #endif /* __NSCANG_CLIENT_H */