Home | History | Annotate | Line # | Download | only in dist
misc.h revision 1.1
      1  1.1  christos /*	$NetBSD: misc.h,v 1.1 2009/06/07 22:19:11 christos Exp $	*/
      2  1.1  christos /* $OpenBSD: misc.h,v 1.38 2008/06/12 20:38:28 dtucker Exp $ */
      3  1.1  christos 
      4  1.1  christos /*
      5  1.1  christos  * Author: Tatu Ylonen <ylo (at) cs.hut.fi>
      6  1.1  christos  * Copyright (c) 1995 Tatu Ylonen <ylo (at) cs.hut.fi>, Espoo, Finland
      7  1.1  christos  *                    All rights reserved
      8  1.1  christos  *
      9  1.1  christos  * As far as I am concerned, the code I have written for this software
     10  1.1  christos  * can be used freely for any purpose.  Any derived versions of this
     11  1.1  christos  * software must be clearly marked as such, and if the derived work is
     12  1.1  christos  * incompatible with the protocol description in the RFC file, it must be
     13  1.1  christos  * called by a name other than "ssh" or "Secure Shell".
     14  1.1  christos  */
     15  1.1  christos 
     16  1.1  christos #ifndef _MISC_H
     17  1.1  christos #define _MISC_H
     18  1.1  christos 
     19  1.1  christos /* misc.c */
     20  1.1  christos 
     21  1.1  christos char	*chop(char *);
     22  1.1  christos char	*strdelim(char **);
     23  1.1  christos int	 set_nonblock(int);
     24  1.1  christos int	 unset_nonblock(int);
     25  1.1  christos void	 set_nodelay(int);
     26  1.1  christos int	 a2port(const char *);
     27  1.1  christos int	 a2tun(const char *, int *);
     28  1.1  christos char	*put_host_port(const char *, u_short);
     29  1.1  christos char	*hpdelim(char **);
     30  1.1  christos char	*cleanhostname(char *);
     31  1.1  christos char	*colon(char *);
     32  1.1  christos long	 convtime(const char *);
     33  1.1  christos char	*tilde_expand_filename(const char *, uid_t);
     34  1.1  christos char	*percent_expand(const char *, ...) __attribute__((__sentinel__));
     35  1.1  christos char	*tohex(const void *, size_t);
     36  1.1  christos void	 sanitise_stdfd(void);
     37  1.1  christos void	 ms_subtract_diff(struct timeval *, int *);
     38  1.1  christos void	 ms_to_timeval(struct timeval *, int);
     39  1.1  christos 
     40  1.1  christos struct passwd *pwcopy(struct passwd *);
     41  1.1  christos const char *ssh_gai_strerror(int);
     42  1.1  christos 
     43  1.1  christos typedef struct arglist arglist;
     44  1.1  christos struct arglist {
     45  1.1  christos 	char    **list;
     46  1.1  christos 	u_int   num;
     47  1.1  christos 	u_int   nalloc;
     48  1.1  christos };
     49  1.1  christos void	 addargs(arglist *, char *, ...)
     50  1.1  christos 	     __attribute__((format(printf, 2, 3)));
     51  1.1  christos void	 replacearg(arglist *, u_int, char *, ...)
     52  1.1  christos 	     __attribute__((format(printf, 3, 4)));
     53  1.1  christos void	 freeargs(arglist *);
     54  1.1  christos 
     55  1.1  christos int	 tun_open(int, int);
     56  1.1  christos 
     57  1.1  christos /* Common definitions for ssh tunnel device forwarding */
     58  1.1  christos #define SSH_TUNMODE_NO		0x00
     59  1.1  christos #define SSH_TUNMODE_POINTOPOINT	0x01
     60  1.1  christos #define SSH_TUNMODE_ETHERNET	0x02
     61  1.1  christos #define SSH_TUNMODE_DEFAULT	SSH_TUNMODE_POINTOPOINT
     62  1.1  christos #define SSH_TUNMODE_YES		(SSH_TUNMODE_POINTOPOINT|SSH_TUNMODE_ETHERNET)
     63  1.1  christos 
     64  1.1  christos #define SSH_TUNID_ANY		0x7fffffff
     65  1.1  christos #define SSH_TUNID_ERR		(SSH_TUNID_ANY - 1)
     66  1.1  christos #define SSH_TUNID_MAX		(SSH_TUNID_ANY - 2)
     67  1.1  christos 
     68  1.1  christos /* Functions to extract or store big-endian words of various sizes */
     69  1.1  christos u_int64_t	get_u64(const void *)
     70  1.1  christos     __attribute__((__bounded__( __minbytes__, 1, 8)));
     71  1.1  christos u_int32_t	get_u32(const void *)
     72  1.1  christos     __attribute__((__bounded__( __minbytes__, 1, 4)));
     73  1.1  christos u_int16_t	get_u16(const void *)
     74  1.1  christos     __attribute__((__bounded__( __minbytes__, 1, 2)));
     75  1.1  christos void		put_u64(void *, u_int64_t)
     76  1.1  christos     __attribute__((__bounded__( __minbytes__, 1, 8)));
     77  1.1  christos void		put_u32(void *, u_int32_t)
     78  1.1  christos     __attribute__((__bounded__( __minbytes__, 1, 4)));
     79  1.1  christos void		put_u16(void *, u_int16_t)
     80  1.1  christos     __attribute__((__bounded__( __minbytes__, 1, 2)));
     81  1.1  christos 
     82  1.1  christos 
     83  1.1  christos /* readpass.c */
     84  1.1  christos 
     85  1.1  christos #define RP_ECHO			0x0001
     86  1.1  christos #define RP_ALLOW_STDIN		0x0002
     87  1.1  christos #define RP_ALLOW_EOF		0x0004
     88  1.1  christos #define RP_USE_ASKPASS		0x0008
     89  1.1  christos 
     90  1.1  christos char	*read_passphrase(const char *, int);
     91  1.1  christos int	 ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
     92  1.1  christos int	 read_keyfile_line(FILE *, const char *, char *, size_t, u_long *);
     93  1.1  christos 
     94  1.1  christos #endif /* _MISC_H */
     95