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