Updated to use the new LIBSSH2_KNOWNHOST API from libssh2. This requires
[libpwmd.git] / src / types.h
blobaea3dac2d19bfc52a8dc9774af293b5a98c2cbb6
1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
2 /*
3 Copyright (C) 2006-2009 Ben Kibbey <bjk@luxsci.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02110-1301 USA
19 #ifndef TYPES_H
20 #define TYPES_H
22 #include <assuan.h>
23 #include <libpwmd.h>
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
29 #ifdef WITH_TCP
30 #include <libssh2.h>
31 #ifndef DNS_USE_GETTIMEOFDAY_FOR_ID
32 #define DNS_USE_GETTIMEOFDAY_FOR_ID 1
33 #endif
34 #include <ares.h>
35 #include <arpa/nameser.h>
36 #endif
38 #ifdef WITH_LIBPTH
39 #include <pth.h>
40 #endif
42 #ifdef ENABLE_NLS
43 #ifdef HAVE_SETLOCALE
44 #include <locale.h>
45 #endif
46 #include "gettext.h"
47 #define N_(msgid) dgettext("libpwmd", msgid)
48 #endif
50 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
52 typedef enum {
53 ASYNC_CMD_NONE,
54 #ifdef WITH_TCP
55 ASYNC_CMD_DNS,
56 ASYNC_CMD_CONNECT,
57 ASYNC_CMD_HOSTKEY,
58 #endif
59 ASYNC_CMD_OPEN,
60 ASYNC_CMD_OPEN2,
61 ASYNC_CMD_SAVE,
62 ASYNC_CMD_SAVE2,
63 } pwmd_async_cmd_t;
65 #ifdef WITH_TCP
66 typedef enum {
67 SSH_RESUME = -1,
68 SSH_NONE,
69 SSH_INIT,
70 SSH_AUTHLIST,
71 SSH_AUTH,
72 SSH_CHANNEL,
73 SSH_SHELL
74 } pwmd_ssh_async_t;
76 typedef struct {
77 char *host;
78 unsigned port;
79 char *username;
80 char *known_hosts;
81 char *identity;
82 char *identity_pub;
83 int fd;
84 gpg_error_t rc;
85 ares_channel chan;
86 int async;
87 struct hostent *he;
88 LIBSSH2_SESSION *session;
89 LIBSSH2_CHANNEL *channel;
90 LIBSSH2_KNOWNHOSTS *kh;
91 struct libssh2_knownhost *hostent;
92 char *hostkey;
93 pwmd_async_cmd_t cmd;
94 pwmd_ssh_async_t state;
95 } pwmd_tcp_conn_t;
96 #endif
98 struct pwm_s {
99 assuan_context_t ctx;
100 #ifdef WITH_TCP
101 pwmd_tcp_conn_t *tcp_conn;
102 pwmd_ip_version_t prot;
103 pwmd_knownhost_cb_t kh_cb;
104 void *kh_data;
105 #endif
106 int fd;
107 pwmd_async_t state;
108 pwmd_async_cmd_t cmd;
109 pwmd_async_cmd_t lastcmd;
110 char *result; // not related to anything the client can see.
111 #ifdef WITH_PINENTRY
112 pid_t pid; // for pinentry timeouts when used with ..async2().
113 assuan_context_t pctx;
114 int nb_fd; // for pwmd_open/save_async2().
115 pid_t nb_pid;
116 char *_password;
117 #endif
118 int pinentry_tries;
119 int pin_try;
120 char *pinentry_path;
121 char *pinentry_tty;
122 char *pinentry_term;
123 char *pinentry_display;
124 char *lcctype;
125 char *lcmessages;
126 char *title;
127 char *prompt;
128 char *desc;
129 char *password;
130 char *filename;
131 int pinentry_timeout;
132 pwmd_passphrase_cb_t passfunc;
133 void *passdata;
134 pwmd_status_cb_t status_func;
135 void *status_data;
136 pwmd_inquire_cb_t inquire_func;
137 void *inquire_data;
138 #ifdef WITH_QUALITY
139 int (*_inquire_func)(void *, const char *);
140 void *_inquire_data;
141 #endif
142 char *name;
145 typedef struct {
146 size_t len;
147 void *buf;
148 } membuf_t;
150 typedef struct {
151 int fd;
152 gpg_error_t error;
153 char password[ASSUAN_LINELENGTH+1];
154 } pwmd_nb_status_t;
156 gpg_error_t _assuan_command(pwm_t *pwm, assuan_context_t ctx,
157 char **result, const char *cmd)
158 __attribute__ ((visibility ("hidden")));
160 gpg_error_t _connect_finalize(pwm_t *pwm)
161 __attribute__ ((visibility ("hidden")));
163 #endif