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 Component */ 17 /** */ 18 /** Transmission Control Protocol (TCP) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define NX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "nx_api.h" 29 #include "nx_tcp.h" 30 31 /* Bring in externs for caller checking code. */ 32 NX_CALLER_CHECKING_EXTERNS 33 34 35 /**************************************************************************/ 36 /* */ 37 /* FUNCTION RELEASE */ 38 /* */ 39 /* _nxde_tcp_socket_peer_info_get PORTABLE C */ 40 /* 6.1 */ 41 /* AUTHOR */ 42 /* */ 43 /* Yuxin Zhou, Microsoft Corporation */ 44 /* */ 45 /* DESCRIPTION */ 46 /* */ 47 /* This function performs error checking on the TCP socket peer info */ 48 /* get service. */ 49 /* */ 50 /* INPUT */ 51 /* */ 52 /* socket_ptr Pointer to the TCP socket */ 53 /* peer_ip_address Pointer to the IP address */ 54 /* of the peer. */ 55 /* peer_port Pointer to the port number */ 56 /* of the peer. */ 57 /* */ 58 /* OUTPUT */ 59 /* */ 60 /* status Actual completion status */ 61 /* NX_PTR_ERROR Invalid pointer input */ 62 /* NX_NOT_ENABLED TCP not enabled on IP instance*/ 63 /* */ 64 /* CALLS */ 65 /* */ 66 /* _nxd_tcp_socket_peer_info_get Actual TCP socket peer info */ 67 /* get function */ 68 /* CALLED BY */ 69 /* */ 70 /* Application Code */ 71 /* */ 72 /* RELEASE HISTORY */ 73 /* */ 74 /* DATE NAME DESCRIPTION */ 75 /* */ 76 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 77 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 78 /* resulting in version 6.1 */ 79 /* */ 80 /**************************************************************************/ _nxde_tcp_socket_peer_info_get(NX_TCP_SOCKET * socket_ptr,NXD_ADDRESS * peer_ip_address,ULONG * peer_port)81UINT _nxde_tcp_socket_peer_info_get(NX_TCP_SOCKET *socket_ptr, 82 NXD_ADDRESS *peer_ip_address, 83 ULONG *peer_port) 84 { 85 86 UINT status; 87 88 89 /* Check for invalid input pointers. */ 90 if ((socket_ptr == NX_NULL) || (socket_ptr -> nx_tcp_socket_id != NX_TCP_ID)) 91 { 92 return(NX_PTR_ERROR); 93 } 94 95 if ((peer_ip_address == NX_NULL) || (peer_port == NX_NULL)) 96 { 97 return(NX_PTR_ERROR); 98 } 99 100 /* Check to see if TCP is enabled. */ 101 if (!(socket_ptr -> nx_tcp_socket_ip_ptr) -> nx_ip_tcp_packet_receive) 102 { 103 return(NX_NOT_ENABLED); 104 } 105 106 /* Check for appropriate caller. */ 107 NX_THREADS_ONLY_CALLER_CHECKING 108 109 /* Call actual TCP socket MSS get function. */ 110 status = _nxd_tcp_socket_peer_info_get(socket_ptr, peer_ip_address, peer_port); 111 112 /* Return completion status. */ 113 return(status); 114 } 115 116