Changeset 728

Show
Ignore:
Timestamp:
01/04/07 20:27:35 (2 years ago)
Author:
oxff
Message:

nepenthes-scriptgen.module-peiros: merged in [ebb2a89e341ac4d2fe83b209c01f70eb] peiros-latest.patch fixing several bugs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nepenthes/branches/nepenthes-scriptgen/modules/module-peiros/TapInterface.cpp

    r688 r728  
    5959TapInterface::TapInterface() : POLLSocket() 
    6060{ 
    61 //      logPF(); 
    6261        m_encapsulator = 0; 
    6362} 
     
    6564bool TapInterface::Init(uint32_t netmask, bool manageRoute) 
    6665{ 
    67 #if defined(__linux_
     66#if defined(__linux__
    6867        logPF(); 
    6968    struct ifreq ifr; 
     
    118117     
    119118    g_Nepenthes->getSocketMgr()->addPOLLSocket(this); 
     119     
     120    addAddress(inet_addr("10.0.0.1")); 
    120121         
    121122        if((m_manageRoute = manageRoute)) 
     
    142143                { 
    143144                        logCrit("Could not add peiros default route: %s!\n", strerror(errno)); 
    144                         //return false; 
     145                        return false; 
    145146                } 
    146147                 
     
    150151        return true; 
    151152#else 
    152         logCrit("this module does not work on your operating system, use linux\n"); 
     153        logCrit("This module does not work on your operating system, use Linux.\n"); 
    153154        return false; 
    154155 
     
    169170bool TapInterface::Exit() 
    170171{ 
    171 #if defined(__linux_
     172#if defined(__linux__
    172173        if(m_manageRoute) 
    173174        { 
     
    250251} 
    251252 
     253void TapInterface::releaseEncapsulator(TapEncapsulator * e) 
     254{ 
     255        if(m_encapsulator == e) 
     256        { 
     257                logInfo("Successful, neccessary release of encapsulator.\n"); 
     258                m_encapsulator = 0; 
     259        } 
     260        else 
     261                logCrit("Race condition bug avoided!\n"); 
     262} 
     263 
    252264bool TapInterface::addAddress(uint32_t address) 
    253265{ 
     
    289301                } 
    290302        } 
    291          
     303 
     304        addr.sin_addr.s_addr = address;          
    292305        logInfo("Added address %s.\n", inet_ntoa(addr.sin_addr)); 
    293306         
     
    300313{ 
    301314        logPF(); 
    302         // TODO: implement 
    303 
     315         
     316        // obsolete 
     317
  • nepenthes/branches/nepenthes-scriptgen/modules/module-peiros/TapInterface.hpp

    r687 r728  
    7070         
    7171        void setEncapsulator(TapEncapsulator * encapsulator); 
     72        void releaseEncapsulator(TapEncapsulator * encapsulator); 
     73         
    7274        int getSocket(); 
    7375        virtual int32_t getsockOpt(int32_t level, int32_t optname,void *optval,socklen_t *optlen); 
  • nepenthes/branches/nepenthes-scriptgen/modules/module-peiros/module-peiros.cpp

    r687 r728  
    138138                port = m_Config->getValInt("module-peiros.port"); 
    139139                 
    140                 timeout = 30
     140                timeout = m_Config->getValInt("module-peiros.timeout")
    141141                 
    142142                if(!initializeNetrange(m_Config->getValString("module-peiros.netrange"))) 
     
    381381                        rbuf = m_peirosParser.renderRequest(&response); 
    382382                        m_Socket->doRespond((char *) rbuf.data(), rbuf.size()); 
    383                        
     383                /*     
    384384                        if(!m_tapInterface->addAddress(m_address)) 
    385385                        { 
    386386                                logCrit("Failed to add address %s to TUN.\n", inet_ntoa(conv)); 
    387387                                return false; 
    388                         } 
     388                        }*/ 
    389389                         
    390390                        m_saidHello = true; 
     
    588588        logPF(); 
    589589 
    590         m_tapInterface->setEncapsulator(0); 
     590        m_tapInterface->releaseEncapsulator(this); 
    591591        return CL_DROP; 
    592592} 
     
    597597        logPF(); 
    598598 
    599         m_tapInterface->setEncapsulator(0); 
     599        m_tapInterface->releaseEncapsulator(this); 
    600600        return CL_DROP; 
    601601} 
     
    603603ConsumeLevel PeirosDialogue::connectionShutdown(Message *msg) 
    604604{ 
     605        m_tapInterface->releaseEncapsulator(this); 
     606         
    605607        logPF(); 
    606608        return CL_DROP;