29 #ifndef _LIBSSH_PRIV_H 30 #define _LIBSSH_PRIV_H 36 #if !defined(HAVE_STRTOULL) 37 # if defined(HAVE___STRTOULL) 38 # define strtoull __strtoull 39 # elif defined(HAVE__STRTOUI64) 40 # define strtoull _strtoui64 41 # elif defined(__hpux) && defined(__LP64__) 42 # define strtoull strtoul 44 # error "no strtoull function found" 48 #if !defined(HAVE_STRNDUP) 49 char *strndup(
const char *s,
size_t n);
52 #ifdef HAVE_BYTESWAP_H 56 #ifdef HAVE_ARPA_INET_H 57 #include <arpa/inet.h> 62 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ 63 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) 87 # define inline __inline 90 # define va_copy(dest, src) (dest = src) 93 # define strcasecmp _stricmp 94 # define strncasecmp _strnicmp 95 # if ! defined(HAVE_ISBLANK) 96 # define isblank(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n' || (ch) == '\r') 99 # define usleep(X) Sleep(((X)+1000)/1000) 102 # define strtok_r strtok_s 104 # if defined(HAVE__SNPRINTF_S) 106 # define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__) 108 # if defined(HAVE__SNPRINTF) 110 # define snprintf _snprintf 112 # if !defined(HAVE_SNPRINTF) 113 # error "no snprintf compatible function found" 118 # if defined(HAVE__VSNPRINTF_S) 120 # define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v)) 122 # if defined(HAVE__VSNPRINTF) 124 # define vsnprintf _vsnprintf 126 # if !defined(HAVE_VSNPRINTF) 127 # error "No vsnprintf compatible function found" 132 # ifndef _SSIZE_T_DEFINED 134 # include <BaseTsd.h> 135 typedef _W64 SSIZE_T ssize_t;
136 # define _SSIZE_T_DEFINED 142 int gettimeofday(
struct timeval *__p,
void *__t);
144 #define _XCLOSESOCKET closesocket 151 #define _XCLOSESOCKET close 155 #include "libssh/libssh.h" 156 #include "libssh/callbacks.h" 159 #ifndef MAX_PACKAT_LEN 160 #define MAX_PACKET_LEN 262144 162 #ifndef ERROR_BUFFERLEN 163 #define ERROR_BUFFERLEN 1024 166 #ifndef CLIENT_BANNER_SSH2 167 #define CLIENT_BANNER_SSH2 "SSH-2.0-libssh_" SSH_STRINGIFY(LIBSSH_VERSION) 170 #ifndef KBDINT_MAX_PROMPT 171 #define KBDINT_MAX_PROMPT 256 174 #define MAX_BUF_SIZE 4096 177 #ifndef HAVE_COMPILER__FUNC__ 178 # ifdef HAVE_COMPILER__FUNCTION__ 179 # define __func__ __FUNCTION__ 181 # error "Your system must provide a __func__ macro" 185 #if defined(HAVE_GCC_THREAD_LOCAL_STORAGE) 186 # define LIBSSH_THREAD __thread 187 #elif defined(HAVE_MSC_THREAD_LOCAL_STORAGE) 188 # define LIBSSH_THREAD __declspec(thread) 190 # define LIBSSH_THREAD 198 #if defined(HAVE_GCC_VOLATILE_MEMORY_PROTECTION) 199 # define LIBSSH_MEM_PROTECTION __asm__ volatile("" : : "r"(&(x)) : "memory") 201 # define LIBSSH_MEM_PROTECTION 211 void ssh_log_function(
int verbosity,
212 const char *
function,
214 #define SSH_LOG(priority, ...) \ 215 _ssh_log(priority, __func__, __VA_ARGS__) 220 const char *
function,
221 const char *format, ...) PRINTF_ATTRIBUTE(4, 5);
229 char error_buffer[ERROR_BUFFERLEN];
232 #define ssh_set_error(error, code, ...) \ 233 _ssh_set_error(error, code, __func__, __VA_ARGS__) 234 void _ssh_set_error(
void *error,
236 const char *
function,
237 const char *descr, ...) PRINTF_ATTRIBUTE(4, 5);
239 #define ssh_set_error_oom(error) \ 240 _ssh_set_error_oom(error, __func__) 241 void _ssh_set_error_oom(
void *error,
const char *
function);
243 #define ssh_set_error_invalid(error) \ 244 _ssh_set_error_invalid(error, __func__) 245 void _ssh_set_error_invalid(
void *error,
const char *
function);
247 void ssh_reset_error(
void *error);
251 int ssh_auth_reply_default(
ssh_session session,
int partial);
252 int ssh_auth_reply_success(
ssh_session session,
int partial);
256 int ssh_send_banner(
ssh_session session,
int is_server);
259 socket_t ssh_connect_host(
ssh_session session,
const char *host,
const char 260 *bind_addr,
int port,
long timeout,
long usec);
261 socket_t ssh_connect_host_nonblocking(
ssh_session session,
const char *host,
262 const char *bind_addr,
int port);
266 unsigned char *bin_to_base64(
const unsigned char *source,
int len);
273 int match_pattern_list(
const char *
string,
const char *pattern,
274 unsigned int len,
int dolower);
275 int match_hostname(
const char *host,
const char *pattern,
unsigned int len);
282 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 286 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 290 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) 293 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) 296 #define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) 299 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) 301 #ifndef HAVE_EXPLICIT_BZERO 302 void explicit_bzero(
void *s,
size_t n);
317 #define discard_const(ptr) ((void *)((uintptr_t)(ptr))) 322 #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) 327 #ifdef HAVE_GCC_NARG_MACRO 334 #define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple 336 #define __VA_NARG__(...) \ 337 (__VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N()) - 1) 338 #define __VA_NARG_(...) \ 339 VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__)) 340 #define __VA_ARG_N( \ 341 _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ 342 _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ 343 _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ 344 _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ 345 _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ 346 _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ 350 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \ 351 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \ 352 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \ 353 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \ 354 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \ 355 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 358 #define __VA_NARG__(...) (-1) 361 #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0) 364 # ifdef WORDS_BIGENDIAN 365 # define htonll(x) (x) 368 (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32)) 373 # ifdef WORDS_BIGENDIAN 374 # define ntohll(x) (x) 377 (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32)) 382 # ifdef HAVE_FALLTHROUGH_ATTRIBUTE 383 # define FALL_THROUGH __attribute__ ((fallthrough)) 385 # define FALL_THROUGH 389 void ssh_agent_state_free(
void *data);
Definition: session.h:102
Definition: connector.c:52