misc.h revision 1.4 1 1.4 christos /* $NetBSD: misc.h,v 1.4 2011/07/25 03:03:10 christos Exp $ */
2 1.4 christos /* $OpenBSD: misc.h,v 1.47 2010/11/21 01:01:13 djm 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.2 christos char *percent_expand(const char *, ...)
35 1.2 christos #if __GNUC_PREREQ__(4, 0)
36 1.2 christos __attribute__((__sentinel__))
37 1.2 christos #endif
38 1.2 christos ;
39 1.1 christos char *tohex(const void *, size_t);
40 1.1 christos void sanitise_stdfd(void);
41 1.1 christos void ms_subtract_diff(struct timeval *, int *);
42 1.1 christos void ms_to_timeval(struct timeval *, int);
43 1.4 christos
44 1.3 adam int timingsafe_bcmp(const void *, const void *, size_t);
45 1.2 christos long long strtonum(const char *, long long, long long, const char **);
46 1.2 christos
47 1.1 christos struct passwd *pwcopy(struct passwd *);
48 1.1 christos const char *ssh_gai_strerror(int);
49 1.1 christos
50 1.1 christos typedef struct arglist arglist;
51 1.1 christos struct arglist {
52 1.1 christos char **list;
53 1.1 christos u_int num;
54 1.1 christos u_int nalloc;
55 1.1 christos };
56 1.4 christos void addargs(arglist *, const char *, ...)
57 1.1 christos __attribute__((format(printf, 2, 3)));
58 1.4 christos void replacearg(arglist *, u_int, const char *, ...)
59 1.1 christos __attribute__((format(printf, 3, 4)));
60 1.1 christos void freeargs(arglist *);
61 1.1 christos
62 1.1 christos int tun_open(int, int);
63 1.1 christos
64 1.1 christos /* Common definitions for ssh tunnel device forwarding */
65 1.1 christos #define SSH_TUNMODE_NO 0x00
66 1.1 christos #define SSH_TUNMODE_POINTOPOINT 0x01
67 1.1 christos #define SSH_TUNMODE_ETHERNET 0x02
68 1.1 christos #define SSH_TUNMODE_DEFAULT SSH_TUNMODE_POINTOPOINT
69 1.1 christos #define SSH_TUNMODE_YES (SSH_TUNMODE_POINTOPOINT|SSH_TUNMODE_ETHERNET)
70 1.1 christos
71 1.1 christos #define SSH_TUNID_ANY 0x7fffffff
72 1.1 christos #define SSH_TUNID_ERR (SSH_TUNID_ANY - 1)
73 1.1 christos #define SSH_TUNID_MAX (SSH_TUNID_ANY - 2)
74 1.1 christos
75 1.1 christos /* Functions to extract or store big-endian words of various sizes */
76 1.1 christos u_int64_t get_u64(const void *)
77 1.2 christos #ifdef __OpenBSD__
78 1.2 christos __attribute__((__bounded__( __minbytes__, 1, 8)))
79 1.2 christos #endif
80 1.2 christos ;
81 1.1 christos u_int32_t get_u32(const void *)
82 1.2 christos #ifdef __OpenBSD__
83 1.2 christos __attribute__((__bounded__( __minbytes__, 1, 4)))
84 1.2 christos #endif
85 1.2 christos ;
86 1.1 christos u_int16_t get_u16(const void *)
87 1.2 christos #ifdef __OpenBSD__
88 1.2 christos __attribute__((__bounded__( __minbytes__, 1, 2)))
89 1.2 christos #endif
90 1.2 christos ;
91 1.1 christos void put_u64(void *, u_int64_t)
92 1.2 christos #ifdef __OpenBSD__
93 1.2 christos __attribute__((__bounded__( __minbytes__, 1, 8)))
94 1.2 christos #endif
95 1.2 christos ;
96 1.1 christos void put_u32(void *, u_int32_t)
97 1.2 christos #ifdef __OpenBSD__
98 1.2 christos __attribute__((__bounded__( __minbytes__, 1, 4)))
99 1.2 christos #endif
100 1.2 christos ;
101 1.1 christos void put_u16(void *, u_int16_t)
102 1.2 christos #ifdef __OpenBSD__
103 1.2 christos __attribute__((__bounded__( __minbytes__, 1, 2)))
104 1.2 christos #endif
105 1.2 christos ;
106 1.1 christos
107 1.4 christos struct bwlimit {
108 1.4 christos size_t buflen;
109 1.4 christos u_int64_t rate, thresh, lamt;
110 1.4 christos struct timeval bwstart, bwend;
111 1.4 christos };
112 1.4 christos
113 1.4 christos void bandwidth_limit_init(struct bwlimit *, u_int64_t, size_t);
114 1.4 christos void bandwidth_limit(struct bwlimit *, size_t);
115 1.4 christos
116 1.4 christos int parse_ipqos(const char *);
117 1.4 christos void mktemp_proto(char *, size_t);
118 1.1 christos
119 1.1 christos /* readpass.c */
120 1.1 christos
121 1.1 christos #define RP_ECHO 0x0001
122 1.1 christos #define RP_ALLOW_STDIN 0x0002
123 1.1 christos #define RP_ALLOW_EOF 0x0004
124 1.1 christos #define RP_USE_ASKPASS 0x0008
125 1.1 christos
126 1.1 christos char *read_passphrase(const char *, int);
127 1.1 christos int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
128 1.1 christos int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *);
129 1.1 christos
130 1.1 christos #endif /* _MISC_H */
131