diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-25 11:54:57 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-25 11:54:57 +1100 |
commit | 5428f646ad32da88ddd04a8c287d595524674fbf (patch) | |
tree | cc1f1e5d7852e1f44d41077f776abf7dab7ac06d /packet.h | |
parent | 9072e1889648988da38b7b81bce95291c1dc3a23 (diff) |
- More reformatting merged from OpenBSD CVS
- Merged OpenBSD CVS changes:
- [channels.c]
report from mrwizard@psu.edu via djm@ibs.com.au
- [channels.c]
set SO_REUSEADDR and SO_LINGER for forwarded ports.
chip@valinux.com via damien@ibs.com.au
- [nchan.c]
it's not an error() if shutdown_write failes in nchan.
- [readconf.c]
remove dead #ifdef-0-code
- [readconf.c servconf.c]
strcasecmp instead of tolower
- [scp.c]
progress meter overflow fix from damien@ibs.com.au
- [ssh-add.1 ssh-add.c]
SSH_ASKPASS support
- [ssh.1 ssh.c]
postpone fork_after_authentication until command execution,
request/patch from jahakala@cc.jyu.fi via damien@ibs.com.au
plus: use daemon() for backgrounding
Diffstat (limited to 'packet.h')
-rw-r--r-- | packet.h | 118 |
1 files changed, 70 insertions, 48 deletions
@@ -13,7 +13,7 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* RCSID("$Id: packet.h,v 1.6 1999/11/24 13:26:22 damien Exp $"); */ | 16 | /* RCSID("$Id: packet.h,v 1.7 1999/11/25 00:54:59 damien Exp $"); */ |
17 | 17 | ||
18 | #ifndef PACKET_H | 18 | #ifndef PACKET_H |
19 | #define PACKET_H | 19 | #define PACKET_H |
@@ -27,10 +27,11 @@ | |||
27 | #include <ssl/bn.h> | 27 | #include <ssl/bn.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | /* Sets the socket used for communication. Disables encryption until | 30 | /* |
31 | packet_set_encryption_key is called. It is permissible that fd_in | 31 | * Sets the socket used for communication. Disables encryption until |
32 | and fd_out are the same descriptor; in that case it is assumed to | 32 | * packet_set_encryption_key is called. It is permissible that fd_in and |
33 | be a socket. */ | 33 | * fd_out are the same descriptor; in that case it is assumed to be a socket. |
34 | */ | ||
34 | void packet_set_connection(int fd_in, int fd_out); | 35 | void packet_set_connection(int fd_in, int fd_out); |
35 | 36 | ||
36 | /* Puts the connection file descriptors into non-blocking mode. */ | 37 | /* Puts the connection file descriptors into non-blocking mode. */ |
@@ -42,20 +43,25 @@ int packet_get_connection_in(void); | |||
42 | /* Returns the file descriptor used for output. */ | 43 | /* Returns the file descriptor used for output. */ |
43 | int packet_get_connection_out(void); | 44 | int packet_get_connection_out(void); |
44 | 45 | ||
45 | /* Closes the connection (both descriptors) and clears and frees | 46 | /* |
46 | internal data structures. */ | 47 | * Closes the connection (both descriptors) and clears and frees internal |
48 | * data structures. | ||
49 | */ | ||
47 | void packet_close(void); | 50 | void packet_close(void); |
48 | 51 | ||
49 | /* Causes any further packets to be encrypted using the given key. The same | 52 | /* |
50 | key is used for both sending and reception. However, both directions | 53 | * Causes any further packets to be encrypted using the given key. The same |
51 | are encrypted independently of each other. Cipher types are | 54 | * key is used for both sending and reception. However, both directions are |
52 | defined in ssh.h. */ | 55 | * encrypted independently of each other. Cipher types are defined in ssh.h. |
56 | */ | ||
53 | void | 57 | void |
54 | packet_set_encryption_key(const unsigned char *key, unsigned int keylen, | 58 | packet_set_encryption_key(const unsigned char *key, unsigned int keylen, |
55 | int cipher_type); | 59 | int cipher_type); |
56 | 60 | ||
57 | /* Sets remote side protocol flags for the current connection. This can | 61 | /* |
58 | be called at any time. */ | 62 | * Sets remote side protocol flags for the current connection. This can be |
63 | * called at any time. | ||
64 | */ | ||
59 | void packet_set_protocol_flags(unsigned int flags); | 65 | void packet_set_protocol_flags(unsigned int flags); |
60 | 66 | ||
61 | /* Returns the remote protocol flags set earlier by the above function. */ | 67 | /* Returns the remote protocol flags set earlier by the above function. */ |
@@ -64,8 +70,10 @@ unsigned int packet_get_protocol_flags(void); | |||
64 | /* Enables compression in both directions starting from the next packet. */ | 70 | /* Enables compression in both directions starting from the next packet. */ |
65 | void packet_start_compression(int level); | 71 | void packet_start_compression(int level); |
66 | 72 | ||
67 | /* Informs that the current session is interactive. Sets IP flags for optimal | 73 | /* |
68 | performance in interactive use. */ | 74 | * Informs that the current session is interactive. Sets IP flags for |
75 | * optimal performance in interactive use. | ||
76 | */ | ||
69 | void packet_set_interactive(int interactive, int keepalives); | 77 | void packet_set_interactive(int interactive, int keepalives); |
70 | 78 | ||
71 | /* Returns true if the current connection is interactive. */ | 79 | /* Returns true if the current connection is interactive. */ |
@@ -86,28 +94,35 @@ void packet_put_bignum(BIGNUM * value); | |||
86 | /* Appends a string to packet data. */ | 94 | /* Appends a string to packet data. */ |
87 | void packet_put_string(const char *buf, unsigned int len); | 95 | void packet_put_string(const char *buf, unsigned int len); |
88 | 96 | ||
89 | /* Finalizes and sends the packet. If the encryption key has been set, | 97 | /* |
90 | encrypts the packet before sending. */ | 98 | * Finalizes and sends the packet. If the encryption key has been set, |
99 | * encrypts the packet before sending. | ||
100 | */ | ||
91 | void packet_send(void); | 101 | void packet_send(void); |
92 | 102 | ||
93 | /* Waits until a packet has been received, and returns its type. */ | 103 | /* Waits until a packet has been received, and returns its type. */ |
94 | int packet_read(int *payload_len_ptr); | 104 | int packet_read(int *payload_len_ptr); |
95 | 105 | ||
96 | /* Waits until a packet has been received, verifies that its type matches | 106 | /* |
97 | that given, and gives a fatal error and exits if there is a mismatch. */ | 107 | * Waits until a packet has been received, verifies that its type matches |
108 | * that given, and gives a fatal error and exits if there is a mismatch. | ||
109 | */ | ||
98 | void packet_read_expect(int *payload_len_ptr, int type); | 110 | void packet_read_expect(int *payload_len_ptr, int type); |
99 | 111 | ||
100 | /* Checks if a full packet is available in the data received so far via | 112 | /* |
101 | packet_process_incoming. If so, reads the packet; otherwise returns | 113 | * Checks if a full packet is available in the data received so far via |
102 | SSH_MSG_NONE. This does not wait for data from the connection. | 114 | * packet_process_incoming. If so, reads the packet; otherwise returns |
103 | 115 | * SSH_MSG_NONE. This does not wait for data from the connection. | |
104 | SSH_MSG_DISCONNECT is handled specially here. Also, | 116 | * SSH_MSG_DISCONNECT is handled specially here. Also, SSH_MSG_IGNORE |
105 | SSH_MSG_IGNORE messages are skipped by this function and are never returned | 117 | * messages are skipped by this function and are never returned to higher |
106 | to higher levels. */ | 118 | * levels. |
119 | */ | ||
107 | int packet_read_poll(int *packet_len_ptr); | 120 | int packet_read_poll(int *packet_len_ptr); |
108 | 121 | ||
109 | /* Buffers the given amount of input characters. This is intended to be | 122 | /* |
110 | used together with packet_read_poll. */ | 123 | * Buffers the given amount of input characters. This is intended to be used |
124 | * together with packet_read_poll. | ||
125 | */ | ||
111 | void packet_process_incoming(const char *buf, unsigned int len); | 126 | void packet_process_incoming(const char *buf, unsigned int len); |
112 | 127 | ||
113 | /* Returns a character (0-255) from the packet data. */ | 128 | /* Returns a character (0-255) from the packet data. */ |
@@ -116,34 +131,41 @@ unsigned int packet_get_char(void); | |||
116 | /* Returns an integer from the packet data. */ | 131 | /* Returns an integer from the packet data. */ |
117 | unsigned int packet_get_int(void); | 132 | unsigned int packet_get_int(void); |
118 | 133 | ||
119 | /* Returns an arbitrary precision integer from the packet data. The integer | 134 | /* |
120 | must have been initialized before this call. */ | 135 | * Returns an arbitrary precision integer from the packet data. The integer |
136 | * must have been initialized before this call. | ||
137 | */ | ||
121 | void packet_get_bignum(BIGNUM * value, int *length_ptr); | 138 | void packet_get_bignum(BIGNUM * value, int *length_ptr); |
122 | 139 | ||
123 | /* Returns a string from the packet data. The string is allocated using | 140 | /* |
124 | xmalloc; it is the responsibility of the calling program to free it when | 141 | * Returns a string from the packet data. The string is allocated using |
125 | no longer needed. The length_ptr argument may be NULL, or point to an | 142 | * xmalloc; it is the responsibility of the calling program to free it when |
126 | integer into which the length of the string is stored. */ | 143 | * no longer needed. The length_ptr argument may be NULL, or point to an |
144 | * integer into which the length of the string is stored. | ||
145 | */ | ||
127 | char *packet_get_string(unsigned int *length_ptr); | 146 | char *packet_get_string(unsigned int *length_ptr); |
128 | 147 | ||
129 | /* Logs the error in syslog using LOG_INFO, constructs and sends a disconnect | 148 | /* |
130 | packet, closes the connection, and exits. This function never returns. | 149 | * Logs the error in syslog using LOG_INFO, constructs and sends a disconnect |
131 | The error message should not contain a newline. The total length of the | 150 | * packet, closes the connection, and exits. This function never returns. |
132 | message must not exceed 1024 bytes. */ | 151 | * The error message should not contain a newline. The total length of the |
152 | * message must not exceed 1024 bytes. | ||
153 | */ | ||
133 | void packet_disconnect(const char *fmt,...); | 154 | void packet_disconnect(const char *fmt,...); |
134 | 155 | ||
135 | /* Sends a diagnostic message to the other side. This message | 156 | /* |
136 | can be sent at any time (but not while constructing another message). | 157 | * Sends a diagnostic message to the other side. This message can be sent at |
137 | The message is printed immediately, but only if the client is being | 158 | * any time (but not while constructing another message). The message is |
138 | executed in verbose mode. These messages are primarily intended to | 159 | * printed immediately, but only if the client is being executed in verbose |
139 | ease debugging authentication problems. The total length of the message | 160 | * mode. These messages are primarily intended to ease debugging |
140 | must not exceed 1024 bytes. This will automatically call | 161 | * authentication problems. The total length of the message must not exceed |
141 | packet_write_wait. If the remote side protocol flags do not indicate | 162 | * 1024 bytes. This will automatically call packet_write_wait. If the |
142 | that it supports SSH_MSG_DEBUG, this will do nothing. */ | 163 | * remote side protocol flags do not indicate that it supports SSH_MSG_DEBUG, |
164 | * this will do nothing. | ||
165 | */ | ||
143 | void packet_send_debug(const char *fmt,...); | 166 | void packet_send_debug(const char *fmt,...); |
144 | 167 | ||
145 | /* Checks if there is any buffered output, and tries to write some of the | 168 | /* Checks if there is any buffered output, and tries to write some of the output. */ |
146 | output. */ | ||
147 | void packet_write_poll(void); | 169 | void packet_write_poll(void); |
148 | 170 | ||
149 | /* Waits until all pending output data has been written. */ | 171 | /* Waits until all pending output data has been written. */ |