misc.h revision 181111
1181111Sdes/* $OpenBSD: misc.h,v 1.38 2008/06/12 20:38:28 dtucker Exp $ */ 276259Sgreen 376259Sgreen/* 476259Sgreen * Author: Tatu Ylonen <ylo@cs.hut.fi> 576259Sgreen * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 676259Sgreen * All rights reserved 776259Sgreen * 876259Sgreen * As far as I am concerned, the code I have written for this software 976259Sgreen * can be used freely for any purpose. Any derived versions of this 1076259Sgreen * software must be clearly marked as such, and if the derived work is 1176259Sgreen * incompatible with the protocol description in the RFC file, it must be 1276259Sgreen * called by a name other than "ssh" or "Secure Shell". 1376259Sgreen */ 1476259Sgreen 15162852Sdes#ifndef _MISC_H 16162852Sdes#define _MISC_H 17162852Sdes 18137015Sdes/* misc.c */ 19137015Sdes 2092555Sdeschar *chop(char *); 2192555Sdeschar *strdelim(char **); 22137015Sdesint set_nonblock(int); 23137015Sdesint unset_nonblock(int); 2492555Sdesvoid set_nodelay(int); 2592555Sdesint a2port(const char *); 26157016Sdesint a2tun(const char *, int *); 27162852Sdeschar *put_host_port(const char *, u_short); 28146998Sdeschar *hpdelim(char **); 2992555Sdeschar *cleanhostname(char *); 3092555Sdeschar *colon(char *); 3192555Sdeslong convtime(const char *); 32149749Sdeschar *tilde_expand_filename(const char *, uid_t); 33149749Sdeschar *percent_expand(const char *, ...) __attribute__((__sentinel__)); 34162852Sdeschar *tohex(const void *, size_t); 35157016Sdesvoid sanitise_stdfd(void); 36181111Sdesvoid ms_subtract_diff(struct timeval *, int *); 37181111Sdesvoid ms_to_timeval(struct timeval *, int); 3876259Sgreen 3992555Sdesstruct passwd *pwcopy(struct passwd *); 40181111Sdesconst char *ssh_gai_strerror(int); 4176259Sgreen 4292555Sdestypedef struct arglist arglist; 4392555Sdesstruct arglist { 4498675Sdes char **list; 45137015Sdes u_int num; 46137015Sdes u_int nalloc; 4792555Sdes}; 48157016Sdesvoid addargs(arglist *, char *, ...) 49157016Sdes __attribute__((format(printf, 2, 3))); 50157016Sdesvoid replacearg(arglist *, u_int, char *, ...) 51157016Sdes __attribute__((format(printf, 3, 4))); 52157016Sdesvoid freeargs(arglist *); 53137015Sdes 54157016Sdesint tun_open(int, int); 55157016Sdes 56157016Sdes/* Common definitions for ssh tunnel device forwarding */ 57157016Sdes#define SSH_TUNMODE_NO 0x00 58157016Sdes#define SSH_TUNMODE_POINTOPOINT 0x01 59157016Sdes#define SSH_TUNMODE_ETHERNET 0x02 60157016Sdes#define SSH_TUNMODE_DEFAULT SSH_TUNMODE_POINTOPOINT 61157016Sdes#define SSH_TUNMODE_YES (SSH_TUNMODE_POINTOPOINT|SSH_TUNMODE_ETHERNET) 62157016Sdes 63157016Sdes#define SSH_TUNID_ANY 0x7fffffff 64157016Sdes#define SSH_TUNID_ERR (SSH_TUNID_ANY - 1) 65157016Sdes#define SSH_TUNID_MAX (SSH_TUNID_ANY - 2) 66162852Sdes 67162852Sdes/* Functions to extract or store big-endian words of various sizes */ 68162852Sdesu_int64_t get_u64(const void *) 69162852Sdes __attribute__((__bounded__( __minbytes__, 1, 8))); 70162852Sdesu_int32_t get_u32(const void *) 71162852Sdes __attribute__((__bounded__( __minbytes__, 1, 4))); 72162852Sdesu_int16_t get_u16(const void *) 73162852Sdes __attribute__((__bounded__( __minbytes__, 1, 2))); 74162852Sdesvoid put_u64(void *, u_int64_t) 75162852Sdes __attribute__((__bounded__( __minbytes__, 1, 8))); 76162852Sdesvoid put_u32(void *, u_int32_t) 77162852Sdes __attribute__((__bounded__( __minbytes__, 1, 4))); 78162852Sdesvoid put_u16(void *, u_int16_t) 79162852Sdes __attribute__((__bounded__( __minbytes__, 1, 2))); 80162852Sdes 81162852Sdes 82162852Sdes/* readpass.c */ 83162852Sdes 84162852Sdes#define RP_ECHO 0x0001 85162852Sdes#define RP_ALLOW_STDIN 0x0002 86162852Sdes#define RP_ALLOW_EOF 0x0004 87162852Sdes#define RP_USE_ASKPASS 0x0008 88162852Sdes 89162852Sdeschar *read_passphrase(const char *, int); 90162852Sdesint ask_permission(const char *, ...) __attribute__((format(printf, 1, 2))); 91162852Sdesint read_keyfile_line(FILE *, const char *, char *, size_t, u_long *); 92162852Sdes 93162852Sdes#endif /* _MISC_H */ 94