10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Author: Tatu Ylonen <ylo@cs.hut.fi> 30Sstevel@tonic-gate * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 40Sstevel@tonic-gate * All rights reserved 50Sstevel@tonic-gate * Interface for the packet protocol functions. 60Sstevel@tonic-gate * 70Sstevel@tonic-gate * As far as I am concerned, the code I have written for this software 80Sstevel@tonic-gate * can be used freely for any purpose. Any derived versions of this 90Sstevel@tonic-gate * software must be clearly marked as such, and if the derived work is 100Sstevel@tonic-gate * incompatible with the protocol description in the RFC file, it must be 110Sstevel@tonic-gate * called by a name other than "ssh" or "Secure Shell". 120Sstevel@tonic-gate */ 130Sstevel@tonic-gate /* 14*5562Sjp161948 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 150Sstevel@tonic-gate * Use is subject to license terms. 160Sstevel@tonic-gate */ 170Sstevel@tonic-gate 18*5562Sjp161948 #ifndef _PACKET_H 19*5562Sjp161948 #define _PACKET_H 20*5562Sjp161948 21*5562Sjp161948 /* $OpenBSD: packet.h,v 1.35 2002/06/19 18:01:00 markus Exp $ */ 22*5562Sjp161948 23*5562Sjp161948 #pragma ident "%Z%%M% %I% %E% SMI" 24*5562Sjp161948 25*5562Sjp161948 #ifdef __cplusplus 26*5562Sjp161948 extern "C" { 27*5562Sjp161948 #endif 28*5562Sjp161948 29*5562Sjp161948 300Sstevel@tonic-gate #include <openssl/bn.h> 31*5562Sjp161948 #include "kex.h" 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef ALTPRIVSEP 340Sstevel@tonic-gate /* Monitor-side functions */ 350Sstevel@tonic-gate void packet_set_server(void); 360Sstevel@tonic-gate void packet_set_no_monitor(void); 370Sstevel@tonic-gate void packet_set_monitor(int pip_fd); 380Sstevel@tonic-gate int packet_is_server(void); 390Sstevel@tonic-gate int packet_is_monitor(void); 400Sstevel@tonic-gate void packet_set_packet(const void *buf, u_int len); 410Sstevel@tonic-gate #endif /* ALTPRIVSEP */ 420Sstevel@tonic-gate 430Sstevel@tonic-gate void packet_set_connection(int, int); 440Sstevel@tonic-gate void packet_set_nonblocking(void); 450Sstevel@tonic-gate int packet_get_connection_in(void); 460Sstevel@tonic-gate int packet_get_connection_out(void); 470Sstevel@tonic-gate void packet_close(void); 480Sstevel@tonic-gate void packet_set_encryption_key(const u_char *, u_int, int); 490Sstevel@tonic-gate u_int packet_get_encryption_key(u_char *); 500Sstevel@tonic-gate void packet_set_protocol_flags(u_int); 510Sstevel@tonic-gate u_int packet_get_protocol_flags(void); 520Sstevel@tonic-gate void packet_start_compression(int); 530Sstevel@tonic-gate void packet_set_interactive(int); 540Sstevel@tonic-gate int packet_is_interactive(void); 550Sstevel@tonic-gate 560Sstevel@tonic-gate void packet_start(u_char); 570Sstevel@tonic-gate void packet_put_char(int ch); 580Sstevel@tonic-gate void packet_put_int(u_int value); 590Sstevel@tonic-gate void packet_put_bignum(BIGNUM * value); 600Sstevel@tonic-gate void packet_put_bignum2(BIGNUM * value); 610Sstevel@tonic-gate void packet_put_string(const void *buf, u_int len); 620Sstevel@tonic-gate void packet_put_cstring(const char *str); 630Sstevel@tonic-gate void packet_put_ascii_cstring(const char *str); 640Sstevel@tonic-gate void packet_put_utf8_cstring(const u_char *str); 650Sstevel@tonic-gate void packet_put_raw(const void *buf, u_int len); 660Sstevel@tonic-gate void packet_send(void); 670Sstevel@tonic-gate 680Sstevel@tonic-gate #if 0 690Sstevel@tonic-gate /* If these are needed, then get rid of the #if 0 and this comment */ 700Sstevel@tonic-gate void packet_put_utf8_string(const u_char *buf, u_int len); 710Sstevel@tonic-gate void packet_put_ascii_string(const char *str, u_int len); 720Sstevel@tonic-gate #endif 730Sstevel@tonic-gate 740Sstevel@tonic-gate int packet_read(void); 750Sstevel@tonic-gate void packet_read_expect(int type); 760Sstevel@tonic-gate int packet_read_poll(void); 770Sstevel@tonic-gate void packet_process_incoming(const char *buf, u_int len); 780Sstevel@tonic-gate int packet_read_seqnr(u_int32_t *seqnr_p); 790Sstevel@tonic-gate int packet_read_poll_seqnr(u_int32_t *seqnr_p); 800Sstevel@tonic-gate 810Sstevel@tonic-gate u_int packet_get_char(void); 820Sstevel@tonic-gate u_int packet_get_int(void); 830Sstevel@tonic-gate void packet_get_bignum(BIGNUM * value); 840Sstevel@tonic-gate void packet_get_bignum2(BIGNUM * value); 850Sstevel@tonic-gate void *packet_get_raw(u_int *length_ptr); 860Sstevel@tonic-gate void *packet_get_string(u_int *length_ptr); 870Sstevel@tonic-gate char *packet_get_ascii_cstring(); 880Sstevel@tonic-gate u_char *packet_get_utf8_cstring(); 890Sstevel@tonic-gate void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2))); 900Sstevel@tonic-gate void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2))); 910Sstevel@tonic-gate 920Sstevel@tonic-gate void set_newkeys(int mode); 93*5562Sjp161948 void free_keys(Newkeys *keys); 940Sstevel@tonic-gate 950Sstevel@tonic-gate void packet_write_poll(void); 960Sstevel@tonic-gate void packet_write_wait(void); 970Sstevel@tonic-gate int packet_have_data_to_write(void); 980Sstevel@tonic-gate int packet_not_very_much_data_to_write(void); 990Sstevel@tonic-gate 1000Sstevel@tonic-gate int packet_connection_is_on_socket(void); 1010Sstevel@tonic-gate int packet_connection_is_ipv4(void); 1020Sstevel@tonic-gate int packet_remaining(void); 1030Sstevel@tonic-gate void packet_send_ignore(int); 1040Sstevel@tonic-gate void packet_add_padding(u_char); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate void tty_make_modes(int, struct termios *); 1070Sstevel@tonic-gate void tty_parse_modes(int, int *); 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate extern int max_packet_size; 1100Sstevel@tonic-gate int packet_set_maxsize(int); 1110Sstevel@tonic-gate #define packet_get_maxsize() max_packet_size 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* don't allow remaining bytes after the end of the message */ 1140Sstevel@tonic-gate #define packet_check_eom() \ 1150Sstevel@tonic-gate do { \ 1160Sstevel@tonic-gate int _len = packet_remaining(); \ 1170Sstevel@tonic-gate if (_len > 0) { \ 1180Sstevel@tonic-gate log("Packet integrity error (%d bytes remaining) at %s:%d", \ 1190Sstevel@tonic-gate _len ,__FILE__, __LINE__); \ 1200Sstevel@tonic-gate packet_disconnect("Packet integrity error."); \ 1210Sstevel@tonic-gate } \ 1220Sstevel@tonic-gate } while (0) 1230Sstevel@tonic-gate 124*5562Sjp161948 int packet_need_rekeying(void); 125*5562Sjp161948 void packet_set_rekey_limit(u_int32_t); 126*5562Sjp161948 1270Sstevel@tonic-gate #ifdef __cplusplus 1280Sstevel@tonic-gate } 1290Sstevel@tonic-gate #endif 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate #endif /* _PACKET_H */ 132