617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan/*******************************************************************************
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * Redistribution and use in source and binary forms, with or without
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * modification, are permitted provided that the following conditions are met:
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * - Redistributions of source code must retain the above copyright notice,
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * this list of conditions and the following disclaimer.
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * - Redistributions in binary form must reproduce the above copyright notice,
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * this list of conditions and the following disclaimer in the documentation
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * and/or other materials provided with the distribution.
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * - Neither the name of Intel Corp. nor the names of its
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * contributors may be used to endorse or promote products derived from this
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * software without specific prior written permission.
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan * POSSIBILITY OF SUCH DAMAGE.
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan *******************************************************************************/
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan#endif // __sun || _LINUX
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logantypedef void (*EventLogCallback)(void *param, LPCTSTR message, WORD eventType);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan static const LMEProtocolVersionMessage MIN_PROT_VERSION;
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan static const LMEProtocolVersionMessage MAX_PROT_VERSION;
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan bool SocketsCreated() { return _sockets_active; }
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan static void _LmeCallback(void *param, void *buffer, unsigned int len, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan static int _isLocalCallback(void *const param, SOCKET s);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan static int _isRemoteCallback(void *const param, SOCKET s);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan unsigned int _getMinMessageLen(LMEMessage *message);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan unsigned int _getMinGlobalMsgLen(LMEGlobalRequestMessage *globalMessage);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan bool _checkMessageAndProtocol(LMEMessage *message, unsigned int len);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _closePortForwardRequest(PortForwardRequest *p);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _apfGlobalRequest(LMEGlobalRequestMessage *globalMessage, unsigned int len, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _apfTcpForwardRequest(LMETcpForwardRequestMessage *tcpFwdReqMsg, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _apfTcpForwardCancel(LMETcpForwardCancelRequestMessage *tcpFwdCnclMsg);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _aptSendUdp(LMEUdpSendToMessage *udpSendToMessage, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _apfProtocolVersion(LMEProtocolVersionMessage *verMsg);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _apfChannelOpen(LMEChannelOpenRequestMessage *chOpenMsg, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan PortForwardRequest *_apfChannelOFail(LMEChannelOpenReplayFailureMessage *chFailMsg);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan PortForwardRequest *_apfChannelClose(LMEChannelCloseMessage *chClMsg);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan PortForwardRequest *_apfChannelData(LMEChannelDataMessage *chDMsg, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _LmeReceive(void *buffer, unsigned int len, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _LmeReceiveCompat(char *buffer, unsigned int len, int *status);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan bool _acceptConnection(SOCKET s, unsigned int port);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan static bool _compareDNSSuffix(std::string AMTDNSSuffix, std::string suffix);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan bool _checkRemoteSupport(bool requestDnsFromAmt = false);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan void _updateEnterpriseAccessStatus(const ATDomainMap &localDNSSuffixes);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan ssize_t _send(int s, const void *buf, size_t len, int &senderr);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan bool _checkListen(std::string address, in_port_t port, int &socket);
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan typedef std::vector<PortForwardRequest *> PortForwardRequestList;
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan typedef std::map<unsigned int, PortForwardRequestList> PortMap;
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan typedef std::map<unsigned int, Channel *> ChannelMap;
617e2443dfc17fe44fd44c0675d6aad2ffc9df42Mark Logan SOCKET _clientSignalSocket; // Used to notify Select() to check new available channels