}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * AsyncSocket_GetRemotePort --
+ *
+ * Given an AsyncSocket object, returns the remote port associated
+ * with it, or an error if the request is meaningless for the underlying
+ * connection.
+ *
+ * Results:
+ * ASOCKERR_SUCCESS or ASOCKERR_INVAL.
+ *
+ * Side effects:
+ *
+ *
+ *----------------------------------------------------------------------------
+ */
+
+int
+AsyncSocket_GetRemotePort(AsyncSocket *asock, // IN
+ uint32 *port) // OUT
+{
+ int ret;
+ if (VALID(asock, getRemotePort)) {
+ AsyncSocketLock(asock);
+ ret = VT(asock)->getRemotePort(asock, port);
+ AsyncSocketUnlock(asock);
+ } else {
+ ret = ASOCKERR_INVAL;
+ }
+ return ret;
+}
+
+
/*
*----------------------------------------------------------------------------
*
int (*getGenericErrno)(AsyncSocket *s);
int (*getFd)(AsyncSocket *asock);
int (*getRemoteIPStr)(AsyncSocket *asock, const char **ipStr);
+ int (*getRemotePort)(AsyncSocket *asock, uint32 *port);
int (*getINETIPStr)(AsyncSocket *asock, int socketFamily, char **ipRetStr);
unsigned int (*getPort)(AsyncSocket *asock);
int (*setCloseOptions)(AsyncSocket *asock, int flushEnabledMaxWaitMsec,
static int AsyncTCPSocketGetGenericErrno(AsyncSocket *s);
static int AsyncTCPSocketGetFd(AsyncSocket *asock);
static int AsyncTCPSocketGetRemoteIPStr(AsyncSocket *asock, const char **ipStr);
+static int AsyncTCPSocketGetRemotePort(AsyncSocket *asock, uint32 *port);
static int AsyncTCPSocketGetINETIPStr(AsyncSocket *asock, int socketFamily,
char **ipRetStr);
static unsigned int AsyncTCPSocketGetPort(AsyncSocket *asock);
AsyncTCPSocketGetGenericErrno,
AsyncTCPSocketGetFd,
AsyncTCPSocketGetRemoteIPStr,
+ AsyncTCPSocketGetRemotePort,
AsyncTCPSocketGetINETIPStr,
AsyncTCPSocketGetPort,
AsyncTCPSocketSetCloseOptions,
}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * AsyncTCPSocketGetRemotePort --
+ *
+ * Given an AsyncTCPSocket object, returns the remote port
+ * associated with it, or an error if the request is meaningless
+ * for the underlying connection.
+ *
+ * Results:
+ * ASOCKERR_SUCCESS or ASOCKERR_GENERIC.
+ *
+ * Side effects:
+ *
+ *
+ *----------------------------------------------------------------------------
+ */
+
+static int
+AsyncTCPSocketGetRemotePort(AsyncSocket *base, // IN
+ uint32 *port) // OUT
+{
+ AsyncTCPSocket *asock = TCPSocket(base);
+ int ret = ASOCKERR_SUCCESS;
+
+ ASSERT(asock);
+
+ if (asock == NULL ||
+ AsyncTCPSocketGetState(asock) != AsyncSocketConnected ||
+ (asock->remoteAddrLen != sizeof(struct sockaddr_in) &&
+ asock->remoteAddrLen != sizeof(struct sockaddr_in6))) {
+ ret = ASOCKERR_GENERIC;
+ } else {
+ *port = AsyncTCPSocketGetPortFromAddr(&asock->remoteAddr);
+ }
+
+ return ret;
+}
+
+
/*
*----------------------------------------------------------------------------
*
int AsyncSocket_GetRemoteIPStr(AsyncSocket *asock,
const char **ipStr);
+/*
+ * Return the remote port associated with this socket if applicable
+ */
+int AsyncSocket_GetRemotePort(AsyncSocket *asock,
+ uint32 *port);
+
int AsyncSocket_GetLocalVMCIAddress(AsyncSocket *asock,
uint32 *cid, uint32 *port);
int AsyncSocket_GetRemoteVMCIAddress(AsyncSocket *asock,