![]() |
|
|||
File indexing completed on 2025-05-11 08:24:31
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSTestSuiteTestsTFTPFS 0007 * 0008 * @brief This header file provides functions used to 0009 * implement network interactions of the UDP network fake for tftpfs tests. 0010 * 0011 * Definitions and declarations of data structures and functions. 0012 */ 0013 0014 /* 0015 * Copyright (C) 2022 embedded brains GmbH & Co. KG 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _TFTPFS_INTERACTIONS_H 0040 #define _TFTPFS_INTERACTIONS_H 0041 0042 #ifdef __cplusplus 0043 extern "C" { 0044 #endif 0045 0046 #define NO_BLOCK_SIZE_OPTION 0 0047 #define NO_WINDOW_SIZE_OPTION 0 0048 #define DO_NOT_WAIT_FOR_ANY_TIMEOUT UINT32_MAX 0049 0050 /** 0051 * @addtogroup RTEMSTestSuiteTestsTFTPFS 0052 * 0053 * @{ 0054 */ 0055 0056 /* 0057 * These functions append an interaction to the list of expected interactions. 0058 * For example, _Tftp_Add_interaction_socket() "means": 0059 * 0060 * * As next interaction, expect that the TFTP client calls function 0061 * socket(). 0062 * * Expect (i.e. check) that this socket() call will get parameter values 0063 * as provided by its parameters `domain`, `type` and `protocol`. 0064 * * This call to socket() shall return value of parameter `result` 0065 * to the TFTP client. 0066 * 0067 * The interactions with functions sendto() and recvfrom() are a bit more 0068 * complicated because specific packets are expected to be received or sent. 0069 * For example, _Tftp_Add_interaction_send_rrq() appends an interaction 0070 * where the TFTP client is expected to call sendto() with an RRQ (Read 0071 * Request) packet. _Tftp_Add_interaction_recv_data() appends an interaction 0072 * where the TFTP client is expected to call recvfrom() and as result it 0073 * receives a data packet (which the interaction writes into the buffer 0074 * which the TFTP client provides as parameter in its the recvfrom() call). 0075 */ 0076 0077 void _Tftp_Add_interaction_socket( 0078 int domain, 0079 int type, 0080 int protocol, 0081 int result 0082 ); 0083 0084 void _Tftp_Add_interaction_close( int fd, int result ); 0085 0086 void _Tftp_Add_interaction_bind( int fd, int family, int result ); 0087 0088 void _Tftp_Add_interaction_send_rrq( 0089 int fd, 0090 const char *filename, 0091 uint16_t dest_port, 0092 const char *dest_addr_str, 0093 uint16_t block_size, 0094 uint16_t window_size, 0095 bool result 0096 ); 0097 0098 void _Tftp_Add_interaction_send_wrq( 0099 int fd, 0100 const char *filename, 0101 uint16_t dest_port, 0102 const char *dest_addr_str, 0103 uint16_t block_size, 0104 uint16_t window_size, 0105 bool result 0106 ); 0107 0108 void _Tftp_Add_interaction_send_ack( 0109 int fd, 0110 uint16_t block_num, 0111 uint16_t dest_port, 0112 const char *dest_addr_str, 0113 bool result 0114 ); 0115 0116 void _Tftp_Add_interaction_send_data( 0117 int fd, 0118 uint16_t block_num, 0119 size_t start, 0120 size_t len, 0121 uint8_t (*get_data)( size_t pos ), 0122 uint16_t dest_port, 0123 const char *dest_addr_str, 0124 bool result 0125 ); 0126 0127 void _Tftp_Add_interaction_send_error( 0128 int fd, 0129 uint16_t error_code, 0130 uint16_t dest_port, 0131 const char *dest_addr_str, 0132 bool result 0133 ); 0134 0135 /* 0136 * _Tftp_Add_interaction_recv_data() permits only a boolean result. 0137 * The TFTP client code does not check `errno` and always behaves as if 0138 * a return of -1 indicates a timeout. Hence 0139 * _Tftp_Add_interaction_recv_data() permits only a boolean result 0140 * and no special value to distinct timeouts from other errors. 0141 */ 0142 void _Tftp_Add_interaction_recv_data( 0143 int fd, 0144 uint32_t timeout_ms, 0145 uint16_t src_port, 0146 const char *src_addr_str, 0147 uint16_t block_num, 0148 size_t start, 0149 size_t len, 0150 uint8_t (*get_data)( size_t pos ), 0151 bool result 0152 ); 0153 0154 void _Tftp_Add_interaction_recv_ack( 0155 int fd, 0156 uint32_t timeout_ms, 0157 uint16_t src_port, 0158 const char *src_addr_str, 0159 uint16_t block_num, 0160 bool result 0161 ); 0162 0163 void _Tftp_Add_interaction_recv_oack( 0164 int fd, 0165 uint32_t timeout_ms, 0166 uint16_t src_port, 0167 const char *src_addr_str, 0168 const char *options, 0169 size_t options_size, 0170 bool result 0171 ); 0172 0173 void _Tftp_Add_interaction_recv_error( 0174 int fd, 0175 uint32_t timeout_ms, 0176 uint16_t src_port, 0177 const char *src_addr_str, 0178 uint16_t error_code, 0179 const char *err_msg, 0180 bool result 0181 ); 0182 0183 /* 0184 * The TFTP client receives a "raw" packet. 0185 * 0186 * Test tests use this function to trigger packet format errors such as: 0187 * 0188 * * Too short packets, 0189 * * Strings without 0-byte at their end 0190 * * Wrong op-codes 0191 */ 0192 void _Tftp_Add_interaction_recv_raw( 0193 int fd, 0194 uint32_t timeout_ms, 0195 uint16_t src_port, 0196 const char *src_addr_str, 0197 size_t len, 0198 const uint8_t *bytes, 0199 bool result 0200 ); 0201 0202 void _Tftp_Add_interaction_recv_nothing( 0203 int fd, 0204 uint32_t timeout_ms 0205 ); 0206 0207 /** @} */ 0208 0209 #ifdef __cplusplus 0210 } 0211 #endif 0212 0213 #endif /* _TFTPFS_INTERACTIONS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |