00001 /*00002 * The Software License00003 * =================================================================================00004 * Copyright (c) 2003-.The Terimber Corporation. All rights reserved.00005 * =================================================================================00006 * Redistributions of source code must retain the above copyright notice, 00007 * this list of conditions and the following disclaimer.00008 * Redistributions in binary form must reproduce the above copyright notice, 00009 * this list of conditions and the following disclaimer in the documentation 00010 * and/or other materials provided with the distribution.00011 * The end-user documentation included with the redistribution, if any, 00012 * must include the following acknowledgment:00013 * "This product includes software developed by the Terimber Corporation."00014 * =================================================================================00015 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE TERIMBER CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR 00019 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00022 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE00024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.00025 * ================================================================================00026 */00027
00028 #include "aiomsg/msg_lsnr.h"00029 #include "base/list.hpp"00030 #include "base/memory.hpp"00031 #include "base/common.hpp"00032 #include "base/number.hpp"00033 #include "base/except.h"00034
00035 BEGIN_TERIMBER_NAMESPACE00036 #pragma pack(4)00037
00038 externexception_tablemsgMsgTable;
00039
00040msg_listener::msg_listener(msg_communicator* communicator_, constconf_listener& info_) :
00041 msg_base(communicator_), _info(info_)
00042 {
00043 }
00044
00045 // virtual 00046msg_listener::~msg_listener()
00047 {
00048 }
00049
00050 // checks if the listener accepted the connection00051 // static00052 void00053msg_listener::accept_address(constguid_t& addr, constconf_listener& linfo, conf_connection& cinfo)
00054 {
00055 if (linfo._accept.empty())
00056 {
00057 for (msg_peer_list_t::const_iterator iter = linfo._reject.begin(); iter != linfo._reject.end(); ++iter)
00058 if (iter->_address == addr)
00059 exception::_throw(MSG_RESULT_ACCESS_DENIED, &msgMsgTable);
00060 }
00061 else00062 {
00063 for (msg_peer_list_t::const_iterator iter = linfo._accept.begin(); iter != linfo._accept.end(); ++iter)
00064 if (iter->_address == addr)
00065 {
00066 cinfo._address = addr;
00067 cinfo._support_crypt = iter->_support_crypt;
00068 cinfo._crypt_external = iter->_crypt;
00069 return;
00070 }
00071
00072 exception::_throw(MSG_RESULT_ACCESS_DENIED, &msgMsgTable);
00073 }
00074
00075 cinfo._address = addr;
00076 cinfo._support_crypt = linfo._support_crypt;
00077 cinfo._crypt_external = linfo._crypt_accept;
00078 }
00079
00080 #pragma pack()00081 END_TERIMBER_NAMESPACE