packet.h revision 224638
1/* $OpenBSD: packet.h,v 1.55 2010/11/13 23:27:50 djm Exp $ */ 2/* $FreeBSD$ */ 3 4/* 5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 6 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7 * All rights reserved 8 * Interface for the packet protocol functions. 9 * 10 * As far as I am concerned, the code I have written for this software 11 * can be used freely for any purpose. Any derived versions of this 12 * software must be clearly marked as such, and if the derived work is 13 * incompatible with the protocol description in the RFC file, it must be 14 * called by a name other than "ssh" or "Secure Shell". 15 */ 16 17#ifndef PACKET_H 18#define PACKET_H 19 20#include <termios.h> 21 22#include <openssl/bn.h> 23#ifdef OPENSSL_HAS_ECC 24#include <openssl/ec.h> 25#endif 26 27void packet_set_connection(int, int); 28void packet_set_timeout(int, int); 29void packet_set_nonblocking(void); 30int packet_get_connection_in(void); 31int packet_get_connection_out(void); 32void packet_close(void); 33void packet_set_encryption_key(const u_char *, u_int, int); 34u_int packet_get_encryption_key(u_char *); 35void packet_set_protocol_flags(u_int); 36u_int packet_get_protocol_flags(void); 37void packet_start_compression(int); 38void packet_set_interactive(int, int, int); 39int packet_is_interactive(void); 40void packet_set_server(void); 41void packet_set_authenticated(void); 42#ifdef NONE_CIPHER_ENABLED 43int packet_get_authentication_state(void); 44#endif 45 46void packet_start(u_char); 47void packet_put_char(int ch); 48void packet_put_int(u_int value); 49void packet_put_int64(u_int64_t value); 50void packet_put_bignum(BIGNUM * value); 51void packet_put_bignum2(BIGNUM * value); 52#ifdef OPENSSL_HAS_ECC 53void packet_put_ecpoint(const EC_GROUP *, const EC_POINT *); 54#endif 55void packet_put_string(const void *buf, u_int len); 56void packet_put_cstring(const char *str); 57void packet_put_raw(const void *buf, u_int len); 58void packet_send(void); 59 60int packet_read(void); 61void packet_read_expect(int type); 62int packet_read_poll(void); 63void packet_process_incoming(const char *buf, u_int len); 64int packet_read_seqnr(u_int32_t *seqnr_p); 65int packet_read_poll_seqnr(u_int32_t *seqnr_p); 66 67u_int packet_get_char(void); 68u_int packet_get_int(void); 69u_int64_t packet_get_int64(void); 70void packet_get_bignum(BIGNUM * value); 71void packet_get_bignum2(BIGNUM * value); 72#ifdef OPENSSL_HAS_ECC 73void packet_get_ecpoint(const EC_GROUP *, EC_POINT *); 74#endif 75void *packet_get_raw(u_int *length_ptr); 76void *packet_get_string(u_int *length_ptr); 77char *packet_get_cstring(u_int *length_ptr); 78void *packet_get_string_ptr(u_int *length_ptr); 79void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2))); 80void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2))); 81 82void set_newkeys(int mode); 83int packet_get_keyiv_len(int); 84void packet_get_keyiv(int, u_char *, u_int); 85int packet_get_keycontext(int, u_char *); 86void packet_set_keycontext(int, u_char *); 87void packet_get_state(int, u_int32_t *, u_int64_t *, u_int32_t *, u_int64_t *); 88void packet_set_state(int, u_int32_t, u_int64_t, u_int32_t, u_int64_t); 89int packet_get_ssh1_cipher(void); 90void packet_set_iv(int, u_char *); 91void *packet_get_newkeys(int); 92 93void packet_write_poll(void); 94void packet_write_wait(void); 95int packet_have_data_to_write(void); 96int packet_not_very_much_data_to_write(void); 97 98int packet_connection_is_on_socket(void); 99int packet_connection_is_ipv4(void); 100int packet_remaining(void); 101void packet_send_ignore(int); 102void packet_add_padding(u_char); 103 104void tty_make_modes(int, struct termios *); 105void tty_parse_modes(int, int *); 106 107void packet_set_alive_timeouts(int); 108int packet_inc_alive_timeouts(void); 109int packet_set_maxsize(u_int); 110u_int packet_get_maxsize(void); 111 112/* don't allow remaining bytes after the end of the message */ 113#define packet_check_eom() \ 114do { \ 115 int _len = packet_remaining(); \ 116 if (_len > 0) { \ 117 logit("Packet integrity error (%d bytes remaining) at %s:%d", \ 118 _len ,__FILE__, __LINE__); \ 119 packet_disconnect("Packet integrity error."); \ 120 } \ 121} while (0) 122 123int packet_need_rekeying(void); 124#ifdef NONE_CIPHER_ENABLED 125void packet_request_rekeying(void); 126#endif 127void packet_set_rekey_limit(u_int32_t); 128 129void packet_backup_state(void); 130void packet_restore_state(void); 131 132void *packet_get_input(void); 133void *packet_get_output(void); 134 135#endif /* PACKET_H */ 136