1 #ifndef __LIBSSH2_TRANSPORT_H 2 #define __LIBSSH2_TRANSPORT_H 3 4 /* Copyright (C) 2007 The Written Word, Inc. All rights reserved. 5 * Copyright (C) 2009-2010 by Daniel Stenberg 6 * Author: Daniel Stenberg <daniel@haxx.se> 7 * 8 * Redistribution and use in source and binary forms, 9 * with or without modification, are permitted provided 10 * that the following conditions are met: 11 * 12 * Redistributions of source code must retain the above 13 * copyright notice, this list of conditions and the 14 * following disclaimer. 15 * 16 * Redistributions in binary form must reproduce the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer in the documentation and/or other materials 19 * provided with the distribution. 20 * 21 * Neither the name of the copyright holder nor the names 22 * of any other contributors may be used to endorse or 23 * promote products derived from this software without 24 * specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 27 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 28 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 36 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 38 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 39 * OF SUCH DAMAGE. 40 * 41 * This file handles reading and writing to the SECSH transport layer. RFC4253. 42 */ 43 44 #include "libssh2_priv.h" 45 #include "packet.h" 46 47 48 /* 49 * libssh2_transport_send 50 * 51 * Send a packet, encrypting it and adding a MAC code if necessary 52 * Returns 0 on success, non-zero on failure. 53 * 54 * The data is provided as _two_ data areas that are combined by this 55 * function. The 'data' part is sent immediately before 'data2'. 'data2' can 56 * be set to NULL (or data2_len to 0) to only use a single part. 57 * 58 * Returns LIBSSH2_ERROR_EAGAIN if it would block or if the whole packet was 59 * not sent yet. If it does so, the caller should call this function again as 60 * soon as it is likely that more data can be sent, and this function MUST 61 * then be called with the same argument set (same data pointer and same 62 * data_len) until ERROR_NONE or failure is returned. 63 * 64 * This function DOES NOT call _libssh2_error() on any errors. 65 */ 66 int _libssh2_transport_send(LIBSSH2_SESSION *session, 67 const unsigned char *data, size_t data_len, 68 const unsigned char *data2, size_t data2_len); 69 70 /* 71 * _libssh2_transport_read 72 * 73 * Collect a packet into the input brigade block only controls whether or not 74 * to wait for a packet to start. 75 * 76 * Returns packet type added to input brigade (PACKET_NONE if nothing added), 77 * or PACKET_FAIL on failure and PACKET_EAGAIN if it couldn't process a full 78 * packet. 79 */ 80 81 /* 82 * This function reads the binary stream as specified in chapter 6 of RFC4253 83 * "The Secure Shell (SSH) Transport Layer Protocol" 84 */ 85 int _libssh2_transport_read(LIBSSH2_SESSION * session); 86 87 #endif /* __LIBSSH2_TRANSPORT_H */ 88