1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** NetX Duo Component */ 17 /** */ 18 /** TELNET Client Protocol */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* APPLICATION INTERFACE DEFINITION RELEASE */ 27 /* */ 28 /* nxd_telnet_client.h PORTABLE C */ 29 /* 6.1.9 */ 30 /* AUTHOR */ 31 /* */ 32 /* Yuxin Zhou, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file defines the NetX Duo TELNET Protocol for Clients, */ 37 /* including all data types and external references. */ 38 /* It is assumed that nx_api.h and nx_port.h have already been */ 39 /* included. */ 40 /* */ 41 /* RELEASE HISTORY */ 42 /* */ 43 /* DATE NAME DESCRIPTION */ 44 /* */ 45 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 46 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 47 /* resulting in version 6.1 */ 48 /* 10-15-2021 Yuxin Zhou Modified comment(s), included */ 49 /* necessary header file, */ 50 /* resulting in version 6.1.9 */ 51 /* */ 52 /**************************************************************************/ 53 54 #ifndef NXD_TELNET_CLIENT_H 55 #define NXD_TELNET_CLIENT_H 56 57 /* Determine if a C++ compiler is being used. If so, ensure that standard 58 C is used to process the API information. */ 59 60 #ifdef __cplusplus 61 62 /* Yes, C++ compiler is present. Use standard C. */ 63 extern "C" { 64 65 #endif 66 67 #include "nx_api.h" 68 69 /* Define the TELNET ID. */ 70 71 #define NX_TELNET_CLIENT_ID 0x54454C4DUL 72 73 74 75 /* Define TELNET TCP socket create options. */ 76 77 #ifndef NX_TELNET_TOS 78 #define NX_TELNET_TOS NX_IP_NORMAL 79 #endif 80 81 #ifndef NX_TELNET_FRAGMENT_OPTION 82 #define NX_TELNET_FRAGMENT_OPTION NX_DONT_FRAGMENT 83 #endif 84 85 86 #ifndef NX_TELNET_TIME_TO_LIVE 87 #define NX_TELNET_TIME_TO_LIVE 0x80 88 #endif 89 90 91 /* Define the TELNET Server TCP port number. */ 92 #ifndef NX_TELNET_SERVER_PORT 93 #define NX_TELNET_SERVER_PORT 23 /* Default Port for TELNET server */ 94 #endif 95 96 /* Define return code constants. */ 97 98 #define NX_TELNET_ERROR 0xF0 /* TELNET internal error */ 99 #define NX_TELNET_TIMEOUT 0xF1 /* TELNET timeout occurred */ 100 #define NX_TELNET_FAILED 0xF2 /* TELNET error */ 101 #define NX_TELNET_NOT_CONNECTED 0xF3 /* TELNET not connected error */ 102 #define NX_TELNET_NOT_DISCONNECTED 0xF4 /* TELNET not disconnected error */ 103 #define NX_TELNET_INVALID_PARAMETER 0xF5 /* Invalid non pointer input to Telnet function */ 104 105 106 /* Define the TELNET Client structure. */ 107 108 typedef struct NX_TELNET_CLIENT_STRUCT 109 { 110 ULONG nx_telnet_client_id; /* TELNET Client ID */ 111 CHAR *nx_telnet_client_name; /* Name of this TELNET client */ 112 NX_IP *nx_telnet_client_ip_ptr; /* Pointer to associated IP structure */ 113 NX_TCP_SOCKET nx_telnet_client_socket; /* Client TELNET socket */ 114 } NX_TELNET_CLIENT; 115 116 117 #ifndef NX_TELNET_SOURCE_CODE 118 119 /* Application caller is present, perform API mapping. */ 120 121 /* Determine if error checking is desired. If so, map API functions 122 to the appropriate error checking front-ends. Otherwise, map API 123 functions to the core functions that actually perform the work. 124 Note: error checking is enabled by default. */ 125 126 #ifdef NX_DISABLE_ERROR_CHECKING 127 128 /* Services without error checking. */ 129 130 #define nxd_telnet_client_connect _nxd_telnet_client_connect 131 #define nx_telnet_client_connect _nx_telnet_client_connect 132 #define nx_telnet_client_create _nx_telnet_client_create 133 #define nx_telnet_client_delete _nx_telnet_client_delete 134 #define nx_telnet_client_disconnect _nx_telnet_client_disconnect 135 #define nx_telnet_client_packet_receive _nx_telnet_client_packet_receive 136 #define nx_telnet_client_packet_send _nx_telnet_client_packet_send 137 138 #else 139 140 /* Services with error checking. */ 141 142 #define nxd_telnet_client_connect _nxde_telnet_client_connect 143 #define nx_telnet_client_connect _nxe_telnet_client_connect 144 #define nx_telnet_client_create _nxe_telnet_client_create 145 #define nx_telnet_client_delete _nxe_telnet_client_delete 146 #define nx_telnet_client_disconnect _nxe_telnet_client_disconnect 147 #define nx_telnet_client_packet_receive _nxe_telnet_client_packet_receive 148 #define nx_telnet_client_packet_send _nxe_telnet_client_packet_send 149 #define nx_telnet_server_create _nxe_telnet_server_create 150 151 #endif 152 153 /* Define the prototypes accessible to the application software. */ 154 UINT nxd_telnet_client_connect(NX_TELNET_CLIENT *my_client, NXD_ADDRESS *server_ip_address, UINT server_port, ULONG wait_option); 155 UINT nx_telnet_client_connect(NX_TELNET_CLIENT *client_ptr, ULONG server_ip_address, UINT server_port, ULONG wait_option); 156 UINT nx_telnet_client_create(NX_TELNET_CLIENT *client_ptr, CHAR *client_name, NX_IP *ip_ptr, ULONG window_size); 157 UINT nx_telnet_client_delete(NX_TELNET_CLIENT *client_ptr); 158 UINT nx_telnet_client_disconnect(NX_TELNET_CLIENT *client_ptr, ULONG wait_option); 159 UINT nx_telnet_client_packet_receive(NX_TELNET_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option); 160 UINT nx_telnet_client_packet_send(NX_TELNET_CLIENT *client_ptr, NX_PACKET *packet_ptr, ULONG wait_option); 161 162 163 #else 164 165 /* TELNET source code is being compiled, do not perform any API mapping. */ 166 UINT _nxde_telnet_client_connect(NX_TELNET_CLIENT *my_client, NXD_ADDRESS *server_ip_address, UINT server_port, ULONG wait_option); 167 UINT _nxd_telnet_client_connect(NX_TELNET_CLIENT *my_client, NXD_ADDRESS *server_ip_address, UINT server_port, ULONG wait_option); 168 169 UINT _nxe_telnet_client_connect(NX_TELNET_CLIENT *client_ptr, ULONG server_ip_address, UINT server_port, ULONG wait_option); 170 UINT _nx_telnet_client_connect(NX_TELNET_CLIENT *client_ptr, ULONG server_ip_address, UINT server_port, ULONG wait_option); 171 UINT _nxe_telnet_client_create(NX_TELNET_CLIENT *client_ptr, CHAR *client_name, NX_IP *ip_ptr, ULONG window_size); 172 UINT _nx_telnet_client_create(NX_TELNET_CLIENT *client_ptr, CHAR *client_name, NX_IP *ip_ptr, ULONG window_size); 173 UINT _nxe_telnet_client_delete(NX_TELNET_CLIENT *client_ptr); 174 UINT _nx_telnet_client_delete(NX_TELNET_CLIENT *client_ptr); 175 UINT _nxe_telnet_client_disconnect(NX_TELNET_CLIENT *client_ptr, ULONG wait_option); 176 UINT _nx_telnet_client_disconnect(NX_TELNET_CLIENT *client_ptr, ULONG wait_option); 177 UINT _nxe_telnet_client_packet_receive(NX_TELNET_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option); 178 UINT _nx_telnet_client_packet_receive(NX_TELNET_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option); 179 UINT _nxe_telnet_client_packet_send(NX_TELNET_CLIENT *client_ptr, NX_PACKET *packet_ptr, ULONG wait_option); 180 UINT _nx_telnet_client_packet_send(NX_TELNET_CLIENT *client_ptr, NX_PACKET *packet_ptr, ULONG wait_option); 181 182 183 #endif 184 185 /* Determine if a C++ compiler is being used. If so, complete the standard 186 C conditional started above. */ 187 #ifdef __cplusplus 188 } 189 #endif 190 191 #endif /* NXD_TELNET_CLIENT_H */ 192