1*0Sstevel@tonic-gate /* $OpenBSD: packet.h,v 1.35 2002/06/19 18:01:00 markus Exp $ */ 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate #ifndef _PACKET_H 4*0Sstevel@tonic-gate #define _PACKET_H 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate #ifdef __cplusplus 9*0Sstevel@tonic-gate extern "C" { 10*0Sstevel@tonic-gate #endif 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate /* 14*0Sstevel@tonic-gate * Author: Tatu Ylonen <ylo@cs.hut.fi> 15*0Sstevel@tonic-gate * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 16*0Sstevel@tonic-gate * All rights reserved 17*0Sstevel@tonic-gate * Interface for the packet protocol functions. 18*0Sstevel@tonic-gate * 19*0Sstevel@tonic-gate * As far as I am concerned, the code I have written for this software 20*0Sstevel@tonic-gate * can be used freely for any purpose. Any derived versions of this 21*0Sstevel@tonic-gate * software must be clearly marked as such, and if the derived work is 22*0Sstevel@tonic-gate * incompatible with the protocol description in the RFC file, it must be 23*0Sstevel@tonic-gate * called by a name other than "ssh" or "Secure Shell". 24*0Sstevel@tonic-gate */ 25*0Sstevel@tonic-gate /* 26*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 27*0Sstevel@tonic-gate * Use is subject to license terms. 28*0Sstevel@tonic-gate */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #include <openssl/bn.h> 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef ALTPRIVSEP 33*0Sstevel@tonic-gate /* Monitor-side functions */ 34*0Sstevel@tonic-gate void packet_set_server(void); 35*0Sstevel@tonic-gate void packet_set_no_monitor(void); 36*0Sstevel@tonic-gate void packet_set_monitor(int pip_fd); 37*0Sstevel@tonic-gate int packet_is_server(void); 38*0Sstevel@tonic-gate int packet_is_monitor(void); 39*0Sstevel@tonic-gate void packet_set_packet(const void *buf, u_int len); 40*0Sstevel@tonic-gate #endif /* ALTPRIVSEP */ 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate void packet_set_connection(int, int); 43*0Sstevel@tonic-gate void packet_set_nonblocking(void); 44*0Sstevel@tonic-gate int packet_get_connection_in(void); 45*0Sstevel@tonic-gate int packet_get_connection_out(void); 46*0Sstevel@tonic-gate void packet_close(void); 47*0Sstevel@tonic-gate void packet_set_encryption_key(const u_char *, u_int, int); 48*0Sstevel@tonic-gate u_int packet_get_encryption_key(u_char *); 49*0Sstevel@tonic-gate void packet_set_protocol_flags(u_int); 50*0Sstevel@tonic-gate u_int packet_get_protocol_flags(void); 51*0Sstevel@tonic-gate void packet_start_compression(int); 52*0Sstevel@tonic-gate void packet_set_interactive(int); 53*0Sstevel@tonic-gate int packet_is_interactive(void); 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate void packet_start(u_char); 56*0Sstevel@tonic-gate void packet_put_char(int ch); 57*0Sstevel@tonic-gate void packet_put_int(u_int value); 58*0Sstevel@tonic-gate void packet_put_bignum(BIGNUM * value); 59*0Sstevel@tonic-gate void packet_put_bignum2(BIGNUM * value); 60*0Sstevel@tonic-gate void packet_put_string(const void *buf, u_int len); 61*0Sstevel@tonic-gate void packet_put_cstring(const char *str); 62*0Sstevel@tonic-gate void packet_put_ascii_cstring(const char *str); 63*0Sstevel@tonic-gate void packet_put_utf8_cstring(const u_char *str); 64*0Sstevel@tonic-gate void packet_put_raw(const void *buf, u_int len); 65*0Sstevel@tonic-gate void packet_send(void); 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate #if 0 68*0Sstevel@tonic-gate /* If these are needed, then get rid of the #if 0 and this comment */ 69*0Sstevel@tonic-gate void packet_put_utf8_string(const u_char *buf, u_int len); 70*0Sstevel@tonic-gate void packet_put_ascii_string(const char *str, u_int len); 71*0Sstevel@tonic-gate #endif 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate int packet_read(void); 74*0Sstevel@tonic-gate void packet_read_expect(int type); 75*0Sstevel@tonic-gate int packet_read_poll(void); 76*0Sstevel@tonic-gate void packet_process_incoming(const char *buf, u_int len); 77*0Sstevel@tonic-gate int packet_read_seqnr(u_int32_t *seqnr_p); 78*0Sstevel@tonic-gate int packet_read_poll_seqnr(u_int32_t *seqnr_p); 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate u_int packet_get_char(void); 81*0Sstevel@tonic-gate u_int packet_get_int(void); 82*0Sstevel@tonic-gate void packet_get_bignum(BIGNUM * value); 83*0Sstevel@tonic-gate void packet_get_bignum2(BIGNUM * value); 84*0Sstevel@tonic-gate void *packet_get_raw(u_int *length_ptr); 85*0Sstevel@tonic-gate void *packet_get_string(u_int *length_ptr); 86*0Sstevel@tonic-gate char *packet_get_ascii_cstring(); 87*0Sstevel@tonic-gate u_char *packet_get_utf8_cstring(); 88*0Sstevel@tonic-gate void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2))); 89*0Sstevel@tonic-gate void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2))); 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate void set_newkeys(int mode); 92*0Sstevel@tonic-gate int packet_get_keyiv_len(int); 93*0Sstevel@tonic-gate void packet_get_keyiv(int, u_char *, u_int); 94*0Sstevel@tonic-gate int packet_get_keycontext(int, u_char *); 95*0Sstevel@tonic-gate void packet_set_keycontext(int, u_char *); 96*0Sstevel@tonic-gate u_int32_t packet_get_seqnr(int); 97*0Sstevel@tonic-gate void packet_set_seqnr(int, u_int32_t); 98*0Sstevel@tonic-gate int packet_get_ssh1_cipher(void); 99*0Sstevel@tonic-gate void packet_set_iv(int, u_char *); 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate void packet_write_poll(void); 102*0Sstevel@tonic-gate void packet_write_wait(void); 103*0Sstevel@tonic-gate int packet_have_data_to_write(void); 104*0Sstevel@tonic-gate int packet_not_very_much_data_to_write(void); 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate int packet_connection_is_on_socket(void); 107*0Sstevel@tonic-gate int packet_connection_is_ipv4(void); 108*0Sstevel@tonic-gate int packet_remaining(void); 109*0Sstevel@tonic-gate void packet_send_ignore(int); 110*0Sstevel@tonic-gate void packet_add_padding(u_char); 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate void tty_make_modes(int, struct termios *); 113*0Sstevel@tonic-gate void tty_parse_modes(int, int *); 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate extern int max_packet_size; 116*0Sstevel@tonic-gate int packet_set_maxsize(int); 117*0Sstevel@tonic-gate #define packet_get_maxsize() max_packet_size 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate /* don't allow remaining bytes after the end of the message */ 120*0Sstevel@tonic-gate #define packet_check_eom() \ 121*0Sstevel@tonic-gate do { \ 122*0Sstevel@tonic-gate int _len = packet_remaining(); \ 123*0Sstevel@tonic-gate if (_len > 0) { \ 124*0Sstevel@tonic-gate log("Packet integrity error (%d bytes remaining) at %s:%d", \ 125*0Sstevel@tonic-gate _len ,__FILE__, __LINE__); \ 126*0Sstevel@tonic-gate packet_disconnect("Packet integrity error."); \ 127*0Sstevel@tonic-gate } \ 128*0Sstevel@tonic-gate } while (0) 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate #ifdef __cplusplus 131*0Sstevel@tonic-gate } 132*0Sstevel@tonic-gate #endif 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate #endif /* _PACKET_H */ 135