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