Changeset 2095

Show
Ignore:
Timestamp:
03/29/12 13:29:03 (11 years ago)
Author:
adi
Message:

DICE-EAP Use vector of pair rather than map for router config

By Philippe Carriere:

router config (m_routes2) is the image of what is really written in the flash.
The meaning of the router and peak space flash content is entirely
manufacturer dependent.

Then even the ordering followed by the destinations may be of importance
so it must be a priori preserved.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/dice_eap.cpp

    r2094 r2095  
    785785    for (unsigned int i=0; i<m_router_nb_entries; ++i) { 
    786786        printMessage("  %d: 0x%02x: %d;\n", i, tmp_entries[i]&0xff, (tmp_entries[i]&0xfff0000)>>16); 
    787         unsigned char dest = tmp_entries[i]&0xff; 
    788787    } 
    789788    return; 
     
    16651664    // decode into the routing map 
    16661665    for(unsigned int i=0; i < nb_routes; i++) { 
    1667         m_routes2[tmp_entries[i]&0xff] = (tmp_entries[i]>>8)&0xff
     1666        m_routes2.push_back(std::make_pair(tmp_entries[i]&0xff, (tmp_entries[i]>>8)&0xff))
    16681667    } 
    16691668    return true; 
     
    17141713EAP::RouterConfig::setupRoute(unsigned char src, unsigned char dest) { 
    17151714    debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::setupRoute( 0x%02x, 0x%02x )\n", src, dest); 
    1716     m_routes2[dest] = src; 
    1717     return true; 
     1715    for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) { 
     1716        if (it->first == dest) { 
     1717          it->second = src; 
     1718          return true; 
     1719        } 
     1720    } 
     1721    m_routes2.push_back(std::make_pair(dest, src)); 
     1722    return false; 
    17181723} 
    17191724 
     
    17211726EAP::RouterConfig::removeRoute(unsigned char src, unsigned char dest) { 
    17221727    debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::removeRoute( 0x%02x, 0x%02x )\n", src, dest); 
    1723     if (m_routes2.count(dest) > 0) { 
    1724         if (src != m_routes2[dest]) { 
     1728    for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) { 
     1729        if (it->first == dest) { 
     1730          if (it->second != src) { 
    17251731            return false; 
    1726         } 
    1727         return removeRoute(dest); 
     1732          } 
     1733          return removeRoute(dest); 
     1734        } 
    17281735    } 
    17291736    return true; 
     
    17331740EAP::RouterConfig::removeRoute(unsigned char dest) { 
    17341741    debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::removeRoute( 0x%02x )\n", dest); 
    1735     m_routes2.erase(dest); 
    1736     if (m_routes2.count(dest) < 1) { 
    1737         return false; 
    1738     } 
    1739     return true; 
     1742    for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) { 
     1743        if (it->first == dest) { 
     1744          m_routes2.erase(it); 
     1745          return true; 
     1746        } 
     1747    } 
     1748    return false; 
    17401749} 
    17411750 
    17421751unsigned char 
    17431752EAP::RouterConfig::getSourceForDestination(unsigned char dest) { 
    1744     if (m_routes2.count(dest) > 0) { 
    1745         return m_routes2[dest]; 
     1753    for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) { 
     1754        if (it->first == dest) { 
     1755          return it->second; 
     1756        } 
    17461757    } 
    17471758    return -1; 
  • trunk/libffado/src/dice/dice_eap.h

    r2094 r2095  
    257257          Sources can be routed to several destinations though. 
    258258          */ 
    259         typedef std::map<unsigned char,unsigned char> RouteVectorV2; 
     259//        typedef std::map<unsigned char,unsigned char> RouteVectorV2; 
     260        typedef std::vector< std::pair<unsigned char,unsigned char> > RouteVectorV2; 
    260261        RouteVectorV2 m_routes2; 
    261262    private: