NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 4231


Ignore:
Timestamp:
Aug 12, 2009, 10:43:44 AM (8 years ago)
Author:
bless
Message:
  • made routingentry variables now private and provided set_...() and get_...() methods instead
  • this should also have reduced memory leaks
  • this should be only code beautifying and not alter any protocol logic, but some code was removed (deletion of allocated objects), because it is now in the set_...() methods
Location:
ntlp/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • ntlp/trunk/src/ntlp_statemodule_api.cpp

    r4224 r4231  
    188188   
    189189  if (r_entry) {
    190     myattr.secure=r_entry->secure;
    191     myattr.reliable=!(r_entry->dmode);
    192 
    193     if (!sii_handle)
    194     {
    195       sii_handle= r_entry->sii_handle;
    196     }
     190          myattr.secure=r_entry->is_secure();
     191          myattr.reliable=!(r_entry->is_dmode());
     192
     193          if (!sii_handle)
     194          {
     195                  sii_handle= r_entry->get_sii_handle();
     196          }
    197197  } else {
    198     // Initial Query/Initial Confirm, D-Mode, unsecure
    199     myattr.secure=false;
    200     myattr.reliable=false;
     198          // Initial Query/Initial Confirm, D-Mode, unsecure
     199          myattr.secure=false;
     200          myattr.reliable=false;
    201201  }
    202202
     
    230230  else
    231231  {
    232     if (r_entry) {
    233       if (r_entry->nl) ip_ttl = r_entry->nl->get_ip_ttl();
    234     }
     232    if (r_entry && r_entry->get_peer_nli())
     233            ip_ttl = r_entry->get_peer_nli()->get_ip_ttl();
    235234  }
    236235
     
    242241  {
    243242    if (r_entry && peer->get_ip_ttl()) {
    244       ip_distance = r_entry->nl->get_ip_ttl() - peer->get_ip_ttl();
     243            ip_distance = r_entry->get_peer_nli()->get_ip_ttl() - peer->get_ip_ttl();
    245244    }
    246245  }
     
    288287       
    289288  if (r_entry) {
    290     myattr.secure=r_entry->secure;
    291     myattr.reliable=!(r_entry->dmode);
     289          myattr.secure= r_entry->is_secure();
     290          myattr.reliable=!(r_entry->is_dmode());
    292291  } else {
    293292    // Initial Query/Initial Confirm, D-Mode, unsecure
    294     myattr.secure=false;
    295     myattr.reliable=false;
     293    myattr.secure= false;
     294    myattr.reliable= false;
    296295  }
    297296
     
    343342void
    344343Statemodule::networknotification(const routingkey* r_key, routingentry* r_entry, APIMsg::error_t status, bool force) {
    345   if ((r_entry->rtstate!=status) || force)
     344  if ((r_entry->get_errstate() != status) || force)
    346345  {
    347346    // save the change
    348     r_entry->rtstate = status;
     347    r_entry->set_errstate(status);
    349348       
    350349    mri* mymri = r_key->mr->copy();
     
    355354    msg->set_source(message::qaddr_coordination);
    356355       
    357     msg->set_networknotification(r_key->nslpid, mysid, mymri, status, r_entry->sii_handle);
     356    msg->set_networknotification(r_key->nslpid, mysid, mymri, status, r_entry->get_sii_handle());
    358357       
    359358    msg->send_to(param.nslptable.get_address(r_key->nslpid));
     
    381380   
    382381  tx_attr_t txattr;
    383   txattr.secure=r_entry->secure;
    384   txattr.reliable=!r_entry->dmode;
     382  txattr.secure=r_entry->is_secure();
     383  txattr.reliable=!r_entry->is_dmode();
    385384  txattr.final_hop = false; // meaningless in this context
    386385
     
    531530      }
    532531
    533       apimsg->set_local_addr(r_entry->local_src->copy());
     532      apimsg->set_local_addr(r_entry->get_local_src()->copy());
    534533
    535534      // set it to qn_awaiting_response
    536       r_entry->state=qn_awaiting_response;
     535      r_entry->set_state(qn_awaiting_response);
    537536     
    538537      // save IP TTL for Query Repetitions (NSLP gives us the IP TTL value)
    539       r_entry->ip_ttl = apimsg->get_ip_ttl();
     538      r_entry->set_ip_ttl(apimsg->get_ip_ttl());
    540539     
    541540      // save GIST Hop count for Query Repetitions (NSLP gives us the hop count value)
    542       r_entry->ghc=apimsg->get_ghc();
     541      r_entry->set_gist_hop_count(apimsg->get_ghc());
    543542     
    544543      // set D-Mode unsecure (we set it here, so we remember it when processing response)
    545       r_entry->dmode=true;
    546       r_entry->secure=false;
     544      r_entry->set_dmode(true);
     545      r_entry->set_secure(false);
    547546     
    548547      // set local default RS_Validity Time
    549       r_entry->rs_validity_time= gconf.getpar<uint32>(gistconf_rs_validity_time);
     548      r_entry->set_rs_validity_time(gconf.getpar<uint32>(gistconf_rs_validity_time));
    550549     
    551550      // initiate sending the Query
     
    572571      }
    573572
    574       apimsg->set_local_addr(r_entry->local_src->copy());
     573      apimsg->set_local_addr(r_entry->get_local_src()->copy());
    575574   
    576575      // set it to qn_awaiting_response
    577       r_entry->state=qn_awaiting_response;
     576      r_entry->set_state(qn_awaiting_response);
    578577           
    579578      // set C-Mode (we set it here, so we remember it when processing response)
    580       r_entry->dmode= false;
     579      r_entry->set_cmode();
    581580           
    582581      // save IP TTL for Query Repetitions (NSLP gives us the IP TTL value)
    583       r_entry->ip_ttl = apimsg->get_ip_ttl();
     582      r_entry->set_ip_ttl(apimsg->get_ip_ttl());
    584583
    585584      // set security option in local state, so we choose a secure protocol if needed when processing response
    586       r_entry->secure= (transtype==tx_cmode) ? false : true;
     585      r_entry->set_secure((transtype==tx_cmode) ? false : true);
    587586
    588587      // set local Default RS_Validity Time
    589       r_entry->rs_validity_time= gconf.getpar<uint32>(gistconf_rs_validity_time);;
     588      r_entry->set_rs_validity_time(gconf.getpar<uint32>(gistconf_rs_validity_time));
    590589           
    591590      // send a Query requesting handshake, this will NOT transfer data payload!
     
    605604  { // routing state exists already
    606605    // save GIST Hop count for Query Repetitions (NSLP gives us the hop count value)
    607     r_entry->ghc=apimsg->get_ghc();
     606    r_entry->set_gist_hop_count(apimsg->get_ghc());
    608607       
    609608    // save IP TTL for any Messages sent on behalf of this SendMessage
    610     r_entry->ip_ttl = apimsg->get_ip_ttl();
    611 
    612     apimsg->set_local_addr(r_entry->local_src->copy());
    613        
    614     switch (r_entry->state)
     609    r_entry->set_ip_ttl(apimsg->get_ip_ttl());
     610
     611    apimsg->set_local_addr(r_entry->get_local_src()->copy());
     612       
     613    switch (r_entry->get_state())
    615614    {
    616615      // there is a handshake in progress, we must queue the data
     
    631630        {
    632631          // if it is set up in D-Mode
    633           if (r_entry->dmode)
     632          if (r_entry->is_dmode())
    634633          {
    635634            // if transfer type is dmode -> OK, send in D-MODE
     
    645644              DLog(param.name, "Routing State set up in D-Mode, however, we need to use C-Mode, so we enqueue the data and prepare a new handshake.");
    646645                       
    647               if (r_entry->state==qn_established)
     646              if (r_entry->get_state() == qn_established)
    648647              {
    649648                DLog(param.name, color[red] << "Upgrading to C-Mode from Querier side" << color[off]);
     
    655654                }
    656655                           
    657                 r_entry->state=qn_awaiting_response;
    658                 r_entry->dmode= false;  // was !(apimsg->get_tx_attr().reliable); unreliabe but secure currently not supported
    659                 r_entry->secure= (apimsg->get_tx_attr().secure);
     656                r_entry->set_state(qn_awaiting_response);
     657                r_entry->set_dmode(false);  // was !(apimsg->get_tx_attr().reliable); unreliabe but secure currently not supported
     658                r_entry->set_secure(apimsg->get_tx_attr().secure);
    660659
    661660                // start NoResponse timer
     
    683682                   
    684683            // if set up cmode with security and transfer type is cmode_sec -> OK, send in C-Mode
    685             if (r_entry->secure && (transtype==tx_cmode_sec))
     684            if (r_entry->is_secure() && (transtype==tx_cmode_sec))
    686685            {
    687686              DLog(param.name, "Routing State set up in C-Mode with security, we use it.");
     
    690689                   
    691690            // if set up cmode without security and transfer type is cmode_sec -> Bad, queue and re-initiate
    692             if (!r_entry->secure && (transtype==tx_cmode_sec))
     691            if (!r_entry->is_secure() && (transtype==tx_cmode_sec))
    693692            {
    694693              DLog(param.name, "Routing State currently in C-Mode without security, queueing data and initiating secure C-Mode setup.");
     
    700699              }
    701700                           
    702               r_entry->state=qn_awaiting_response;
    703 
    704               r_entry->dmode= false; // unreliable but secure currently not supported
    705               r_entry->secure= (apimsg->get_tx_attr().secure);
     701              r_entry->set_state(qn_awaiting_response);
     702
     703              r_entry->set_dmode(false); // unreliable but secure currently not supported
     704              r_entry->set_secure(apimsg->get_tx_attr().secure);
    706705
    707706              // start NoResponse timer
     
    723722      default:
    724723        {
    725           ERRCLog(param.name, "Routing State available - Invalid State " << r_entry->state);
    726           break;
     724                ERRCLog(param.name, "Routing State available - Invalid State " << r_entry->get_state());
     725                break;
    727726        }               
    728727    } // end switch
     
    772771
    773772  // do something in case of Routing State in rn_querynslp
    774   if (r_entry->state == rn_querynslp)
     773  if (r_entry->get_state() == rn_querynslp)
    775774  {
    776775    DLog(param.name, "State in RN_QUERYNSLP");
    777776       
    778777    // take the saved PDU, remove it from entry
    779     known_ntlp_pdu* reqpdu = r_entry->tmppdu;
    780     r_entry->tmppdu=NULL;
     778    known_ntlp_pdu* reqpdu = r_entry->deliver_tmppdu();
    781779       
    782780    if (!reqpdu)
     
    784782       
    785783    // take the saved Peer
    786     appladdress* peer = r_entry->tmppeer;
    787     r_entry->tmppeer=NULL;
     784    appladdress* peer = r_entry->deliver_tmppeer();
    788785       
    789786    if (!peer)
     
    795792      // save data payload in entry, for repetitions of responses
    796793      if (apimsg->get_data())
    797         r_entry->mod_data=new nslpdata(*apimsg->get_data());
     794              r_entry->set_mod_data(apimsg->get_data());
    798795           
    799796      //##############################################################
     
    817814        DLog(param.name, "Immediate state installation configured, set up state");
    818815               
    819         r_entry->rs_validity_time = gconf.getpar<uint32>(gistconf_rs_validity_time);
     816        r_entry->set_rs_validity_time(gconf.getpar<uint32>(gistconf_rs_validity_time));
    820817       
    821818        // put in state "rn_established"
     
    825822                   
    826823          // install Routing State
    827           if (!r_entry->dmode)
     824          if (!r_entry->is_dmode())
    828825          {
    829826            // install Routing State, note that add_ma will store the address as IPv6
    830             param.rt.add_ma(r_entry->nl->copy(), *peer, r_entry->ma_hold_time, true);
     827                  param.rt.add_ma(r_entry->get_peer_nli()->copy(), *peer, r_entry->get_ma_hold_time(), true);
    831828          }
    832829          networknotification(r_key, r_entry, APIMsg::route_changed_status_good, false);
    833830                   
    834           r_entry->state= rn_established;
     831          r_entry->set_state(rn_established);
    835832          // Start Expire_RNode timer!
    836           starttimer(r_key, r_entry, expire_rnode, 0, r_entry->rs_validity_time);
     833          starttimer(r_key, r_entry, expire_rnode, 0, r_entry->get_rs_validity_time());
    837834                   
    838835          // set retry timeout back to default
     
    845842        {
    846843          DLog(param.name, "Full handshake is configured, waiting for GIST Confirm");
    847           r_entry->state=rn_awaiting_confirm;
     844          r_entry->set_state(rn_awaiting_confirm);
    848845                   
    849846          starttimer(r_key, r_entry, noconfirm, 0, r_entry->reset_retry_timeout());
     
    896893      // send it to signaling
    897894      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    898       sigmsg->set_local_addr(r_entry->local_src->copy());
     895      sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    899896      sigmsg->set_req(peer, reqpdu);
    900897      sigmsg->send_or_delete();
  • ntlp/trunk/src/ntlp_statemodule_data.cpp

    r4210 r4231  
    118118    if (r_entry->is_responding_node())
    119119      sigmsg->set_useexistconn();
    120     sigmsg->set_local_addr(r_entry->local_src->copy());
     120    sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    121121    param.rt.unlock(&myrkey);
    122122  }
     
    139139Statemodule::send_data_dmode(nslpdata*  nslp_data, routingkey* r_key, routingentry* r_entry,  msghandle_t msghandle)
    140140{
    141   if (r_entry->state==qn_established || r_entry->state==qn_awaiting_refresh)
     141  if (r_entry->get_state()==qn_established || r_entry->get_state()==qn_awaiting_refresh)
    142142  {
    143143    // Restart InactiveQNode timer (running on slot 1)
    144     starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->rs_validity_time);
     144    starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->get_rs_validity_time());
    145145  }
    146146
    147147  // save Message ID for this Message (in case there will be an error)
    148   r_entry->msg_id=msghandle;
     148  r_entry->set_msg_id(msghandle);
    149149 
    150150  appladdress* peer= new appladdress;
     
    152152  peer->set_protocol(param.udp);
    153153 
    154   peer->set_ip(r_entry->nl->get_if_address());
     154  peer->set_ip(r_entry->get_peer_nli()->get_if_address());
    155155 
    156156  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
    157   sigmsg->set_local_addr(r_entry->local_src->copy());
     157  sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    158158
    159159  // Build a DATA Message
     
    169169  mri* mymri=r_key->mr->copy();
    170170   
    171   nli* own_nli=build_local_nli(mymri->get_ip_version(), r_entry->nl->get_if_address(), r_entry);
    172    
    173   own_nli->set_ip_ttl(r_entry->ip_ttl);
     171  nli* own_nli=build_local_nli(mymri->get_ip_version(), r_entry->get_peer_nli()->get_if_address(), r_entry);
     172   
     173  own_nli->set_ip_ttl(r_entry->get_ip_ttl());
    174174   
    175175
     
    178178
    179179  pdu->set_nslpid(r_key->nslpid);
    180   pdu->set_hops(r_entry->ghc);
     180  pdu->set_hops(r_entry->get_gist_hop_count());
    181181 
    182182  // if explicit routing took place (sending for DEAD state)
    183   if (r_entry->state==dead)
     183  if (r_entry->get_state() == dead)
    184184  { 
    185185    pdu->set_E(); 
     
    215215{
    216216
    217   if (r_entry->state==qn_established || r_entry->state==qn_awaiting_refresh)
     217  if (r_entry->get_state() == qn_established || r_entry->get_state() == qn_awaiting_refresh)
    218218  {
    219219    // Restart InactiveQNode timer (running on slot 1)
    220     starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->rs_validity_time);
    221   }
    222    
    223   appladdress* peer= param.rt.lookup_ma_peeraddress(r_entry->nl);
     220    starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->get_rs_validity_time());
     221  }
     222   
     223  appladdress* peer= param.rt.lookup_ma_peeraddress(r_entry->get_peer_nli());
    224224  if (peer)
    225225  {
    226226    // indicate activity to MA maintainance
    227     param.rt.activity_ind_ma(r_entry->nl);
     227    param.rt.activity_ind_ma(r_entry->get_peer_nli());
    228228
    229229    SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
    230     sigmsg->set_local_addr(r_entry->local_src->copy());
     230    sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    231231   
    232232    // Build a DATA Message
     
    269269      enqueuedata(r_key, r_entry, payload, data_keep_timeout, msghandle);
    270270     
    271       r_entry->state=qn_awaiting_response;
     271      r_entry->set_state(qn_awaiting_response);
    272272
    273273      // start NoResponse timer   
     
    323323      mydata=entry->dataqueue[i]->data;   
    324324      // this cannot be explicitly routed, as we would not use C-Mode
    325       if (entry->dmode) {
     325      if (entry->is_dmode()) {
    326326        send_data_dmode(mydata, key, entry, entry->dataqueue[i]->msghandle);
    327327      }
     
    351351  {
    352352
    353     if (r_entry->timer_type_3 != queue_poll) {
     353      if (r_entry->get_timer_type_3() != queue_poll) {
    354354      DLog(param.name, "Deliberately stopped timer, ignoring");
    355355      param.rt.unlock(r_key);
     
    357357    }
    358358
    359     if (r_entry->timer_id_3 == timermsg->get_id())
     359    if (r_entry->get_timer_id_3() == timermsg->get_id())
    360360    {
    361361      DLog(param.name, "Timer slot 3, timer is valid, id: " << timermsg->get_id());
     
    406406       
    407407        // avoid stopping a non-running timer when queue poll timer is restarted
    408         r_entry->timer_type_3= none;
    409         r_entry->timer_id_3= 0;
     408        r_entry->set_timer_type_3(none);
     409        r_entry->set_timer_id_3(0);
    410410      }
    411411           
  • ntlp/trunk/src/ntlp_statemodule_main.cpp

    r4210 r4231  
    491491{
    492492  nli *mynl;
    493   uint32 rs_validity_time= re ? re->rs_validity_time : gconf.getpar<uint32>(gistconf_rs_validity_time);
     493  uint32 rs_validity_time= re ? re->get_rs_validity_time() : gconf.getpar<uint32>(gistconf_rs_validity_time);
    494494
    495495  if (re) {
    496     mynl = param.nli_tmpl.copy2(*re->local_src);
     496    mynl = param.nli_tmpl.copy2(*re->get_local_src());
    497497    mynl->set_rs_validity_time(rs_validity_time);
    498498  } else {
     
    540540        if (tmpentry)
    541541        {
    542           if (tmpentry->state==qn_established)
    543           {
    544             if (tmpentry->dmode)
    545               send_confirm_dmode(NULL, &tmpkey, tmpentry);
    546             else
    547               send_confirm_cmode(NULL, &tmpkey, tmpentry);
     542          if (tmpentry->get_state() == qn_established)
     543          {
     544                  if (tmpentry->is_dmode())
     545                          send_confirm_dmode(NULL, &tmpkey, tmpentry);
     546                  else
     547                          send_confirm_cmode(NULL, &tmpkey, tmpentry);
    548548          }
    549549        }
     
    868868      else
    869869      {
    870         param.rt.activity_ind_ma(r_entry->nl);
     870              param.rt.activity_ind_ma(r_entry->get_peer_nli());
    871871      }
    872872    } // endif message came via C-Mode
    873873   
    874     if (r_entry->mod_data)
     874    if (r_entry->get_mod_data())
    875875    {
    876876      DLog(param.name, "Cleaning away saved modified data payload for Response repeats");
    877877
    878       //nslpdata* temp = r_entry->mod_data;
    879       r_entry->mod_data=NULL;
    880       //if (temp) delete temp;
     878      r_entry->set_mod_data(NULL);
    881879    }
    882880
     
    884882    if ( incoming_pdu->get_nslpdata() )
    885883    {
    886       if (r_entry->state==rn_established || r_entry->state==rn_awaiting_refresh ||
    887           r_entry->state==qn_established || r_entry->state==qn_awaiting_refresh )
     884            if (r_entry->get_state()==rn_established || r_entry->get_state()==rn_awaiting_refresh ||
     885                r_entry->get_state()==qn_established || r_entry->get_state()==qn_awaiting_refresh )
    888886      {
    889887        // if QNode, reStart inactive_QNode timer
    890888        if (r_entry->is_querying_node())
    891           starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->rs_validity_time);
     889                starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->get_rs_validity_time());
    892890
    893891        EVLog(param.name, "Delivering Payload to NSLP");
     
    900898
    901899    DLog(param.name, "Evaluating current routing state");
    902     switch (r_entry->state)
     900    switch (r_entry->get_state())
    903901    {
    904902      case rn_awaiting_confirm:
     
    10111009
    10121010            // update query cookie
    1013             delete r_entry->qrc;
    1014             r_entry->qrc=new querycookie(*(incoming_pdu->get_querycookie()));
     1011            r_entry->set_querycookie(incoming_pdu->get_querycookie());
    10151012
    10161013            // update temporary saved PDU
    1017             delete r_entry->tmppdu;
    1018             r_entry->tmppdu= incoming_pdu->copy();
     1014            r_entry->set_tmppdu(incoming_pdu);
    10191015
    10201016            // update MA hold time if it is different from the first query
    10211017            if (incoming_pdu->get_stackconf()
    10221018                &&
    1023                 incoming_pdu->get_stackconf()->get_ma_hold_time() != r_entry->ma_hold_time)
     1019                incoming_pdu->get_stackconf()->get_ma_hold_time() != r_entry->get_ma_hold_time())
    10241020            {
    1025               r_entry->ma_hold_time = incoming_pdu->get_stackconf()->get_ma_hold_time();
    1026               DLog(param.name, "Updated MA Hold time: " << r_entry->ma_hold_time);
     1021                    r_entry->set_ma_hold_time(incoming_pdu->get_stackconf()->get_ma_hold_time());
     1022              DLog(param.name, "Updated MA Hold time: " << r_entry->get_ma_hold_time());
    10271023            }
    10281024          } // endif is query
     
    13371333  if (timer == queue_poll)
    13381334  {
    1339     if ((r_entry->timer_id_3 != 0) && stop)
     1335    if ((r_entry->get_timer_id_3() != 0) && stop)
    13401336    {
    13411337      // stop the current timer
    13421338      TimerMsg* stopmsg = new TimerMsg(message::qaddr_coordination, true);
    1343       stopmsg->stop(r_entry->timer_id_3);
     1339      stopmsg->stop(r_entry->get_timer_id_3());
    13441340      stopmsg->send_to(message::qaddr_timer);
    13451341    }
     
    13471343    TimerMsg* msg = new RoutingTableTimerMsg(*r_key, timer, sec, msec);
    13481344
    1349     r_entry->timer_type_3 = timer;
    1350     r_entry->timer_id_3 = msg->get_id();
    1351     mid = r_entry->timer_id_3;
     1345    r_entry->set_timer_type_3(timer);
     1346    r_entry->set_timer_id_3(msg->get_id());
     1347    mid = r_entry->get_timer_id_3();
    13521348
    13531349    msg->send_to(message::qaddr_timer);
     
    13581354  if ((timer == noresponse) || (timer==refresh_qnode))
    13591355  {
    1360     if ((r_entry->timer_id_2 != 0) && stop)
     1356    if ((r_entry->get_timer_id_2() != 0) && stop)
    13611357    {
    13621358      // stop the current timer
    13631359      TimerMsg* stopmsg = new TimerMsg(message::qaddr_coordination, true);
    1364       stopmsg->stop(r_entry->timer_id_2);
     1360      stopmsg->stop(r_entry->get_timer_id_2());
    13651361      stopmsg->send_to(message::qaddr_timer);
    13661362    }
     
    13681364    TimerMsg* msg = new RoutingTableTimerMsg(*r_key, timer, sec, msec);
    13691365
    1370     r_entry->timer_type_2 = timer;
    1371     r_entry->timer_id_2 = msg->get_id();
    1372     mid = r_entry->timer_id_2;
     1366    r_entry->set_timer_type_2(timer);
     1367    r_entry->set_timer_id_2(msg->get_id());
     1368    mid = r_entry->get_timer_id_2();
    13731369
    13741370    msg->send_to(message::qaddr_timer);
     
    13781374  if ((timer == noconfirm) || (timer == expire_rnode) || (timer == inactive_qnode))
    13791375  {
    1380     if ((r_entry->timer_id != 0) && stop)
     1376    if ((r_entry->get_timer_id_1() != 0) && stop)
    13811377    {
    13821378      // stop the current timer
    13831379      TimerMsg* stopmsg = new TimerMsg(message::qaddr_coordination, true);
    1384       stopmsg->stop(r_entry->timer_id);
     1380      stopmsg->stop(r_entry->get_timer_id_1());
    13851381      stopmsg->send_to(message::qaddr_timer);
    13861382    }
     
    13881384    TimerMsg* msg = new RoutingTableTimerMsg(*r_key, timer, sec, msec);
    13891385
    1390     r_entry->timer_type = timer;
    1391     r_entry->timer_id = msg->get_id();
    1392     mid = r_entry->timer_id;
     1386    r_entry->set_timer_type_1(timer);
     1387    r_entry->set_timer_id_1(msg->get_id());
     1388    mid = r_entry->get_timer_id_1();
    13931389
    13941390    msg->send_to(message::qaddr_timer);
     
    14051401  if (timer==refresh_qnode)
    14061402  {
    1407     r_entry->timer_type_2 = none;
     1403          r_entry->set_timer_type_2(none);
    14081404  }
    14091405}
     
    14151411{
    14161412  // timers on slot #2
    1417   if (r_entry->timer_type_2 != none)
     1413  if (r_entry->get_timer_type_2() != none)
    14181414  {
    14191415    // this will cause only ignoring any timer
    1420     r_entry->timer_type_2 = none;
     1416    r_entry->set_timer_type_2(none);
    14211417
    14221418    EVLog(param.name, color[magenta] << "Trying to stop timer on slot 2" << color[off]);
    14231419    // really stop the current timer
    14241420    TimerMsg* stopmsg = new TimerMsg(message::qaddr_coordination, true);
    1425     stopmsg->stop(r_entry->timer_id_2);
     1421    stopmsg->stop(r_entry->get_timer_id_2());
    14261422    stopmsg->send_to(message::qaddr_timer);
    14271423    // this will cause only ignoring any timer
     
    14301426
    14311427  // timers on slot #3
    1432   if (r_entry->timer_type_3 != none)
     1428  if (r_entry->get_timer_type_3() != none)
    14331429  {
    14341430    // this will cause only ignoring any timer
    1435     r_entry->timer_type_3 = none;
     1431    r_entry->set_timer_type_3(none);
    14361432
    14371433    EVLog(param.name, color[magenta] << "Trying to stop timer on slot 3" << color[off]);
    14381434    // really stop the current timer
    14391435    TimerMsg* stopmsg = new TimerMsg(message::qaddr_coordination, true);
    1440     stopmsg->stop(r_entry->timer_id_3);
     1436    stopmsg->stop(r_entry->get_timer_id_3());
    14411437    stopmsg->send_to(message::qaddr_timer);
    14421438  }
     
    15211517  if (tmpentry)
    15221518  {
    1523     if (tmpentry->timer_type_2 == none)
     1519    if (tmpentry->get_timer_type_2() == none)
    15241520    {
    15251521      EVLog(param.name, "Route Flapping occured, restarting refresh_qnode timer for downstream path");
    15261522           
    1527       starttimer(&tmpkey, tmpentry, refresh_qnode, 0, randomized(tmpentry->nl->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
     1523      starttimer(&tmpkey, tmpentry, refresh_qnode, 0, randomized(tmpentry->get_peer_nli()->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
    15281524    }
    15291525  }
  • ntlp/trunk/src/ntlp_statemodule_querier.cpp

    r4210 r4231  
    106106    if (r_entry)
    107107    {
    108       r_entry->msg_id = apimsg->get_nslpmsghandle();
    109       r_entry->ghc = apimsg->get_ghc();
     108            r_entry->set_msg_id(apimsg->get_nslpmsghandle());
     109            r_entry->set_gist_hop_count(apimsg->get_ghc());
    110110    }   
    111111  }
     
    148148
    149149  // set IP TTL on peer address
    150   if (r_entry->ip_ttl)
    151   {
    152     peer->set_ip_ttl(r_entry->ip_ttl);
     150  if (r_entry->get_ip_ttl())
     151  {
     152          peer->set_ip_ttl(r_entry->get_ip_ttl());
    153153       
    154     DLog(param.name, "Set request for IP TTL value of " << r_entry->ip_ttl << " for GIST Query");
     154          DLog(param.name, "Set request for IP TTL value of " << r_entry->get_ip_ttl() << " for GIST Query");
    155155  }
    156156
     
    164164
    165165  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
    166   sigmsg->set_local_addr(r_entry->local_src->copy());
     166  sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    167167   
    168168  DLog(param.name, "Setting Port and Protocol");
     
    196196          if (r_entry)
    197197          {
    198             if ((r_entry)->mod_data)
    199             {   
    200               delete r_entry->mod_data;
    201               r_entry->mod_data= data->copy();
    202             }
     198              r_entry->set_mod_data(data);
    203199          }
    204200        }
     
    214210      if (r_entry)
    215211      {
    216         if (r_entry->mod_data)
    217           data= new nslpdata(*(r_entry->mod_data));
     212          if (r_entry->get_mod_data())
     213                  data= r_entry->get_mod_data()->copy();
    218214      }
    219215    }
     
    222218  querycookie* myqc= query_cookie(r_key);
    223219
    224   r_entry->qrc = myqc->copy();
     220  r_entry->set_querycookie(myqc);
    225221
    226222  // let dedicated function build our NLI
     
    237233  {
    238234    // set IP TTL as it was saved for us from APIMsg processing
    239     if (r_entry->ip_ttl)
    240     {
    241         mynli->set_ip_ttl(r_entry->ip_ttl);
    242         DLog(param.name, "Success!");
     235    if (r_entry->get_ip_ttl())
     236    {
     237            mynli->set_ip_ttl(r_entry->get_ip_ttl());
     238            DLog(param.name, "Success!");
    243239    }
    244240  }
     
    249245  if (handshake)
    250246  {
    251     bool secure= apimsg ? apimsg->get_tx_attr().secure :  r_entry->secure;
     247    bool secure= apimsg ? apimsg->get_tx_attr().secure :  r_entry->is_secure();
    252248
    253249    sp= cap.query_stackprop(secure);
     
    307303
    308304  // set GIST Hop Count
    309   pdu->set_hops(r_entry->ghc);
     305  pdu->set_hops(r_entry->get_gist_hop_count());
    310306
    311307  DLog(param.name, "Set GIST Hop Count to " << (int) pdu->get_hops());
     
    369365  if (peer->get_protocol() != param.udp)
    370366  {
    371     if ( r_entry->secure && cap.is_secure(peer)==false )
     367    if ( r_entry->is_secure() && cap.is_secure(peer)==false )
    372368    {
    373369      // Response came via non-secure connection
     
    378374  }
    379375
    380   if (!r_entry->qrc)
     376  if (!r_entry->get_querycookie())
    381377  {
    382378    ERRCLog(param.name, "No Local stored Query Cookie, dropping");
     
    390386 
    391387  // Check whether  Query Cookie matches, if so we accept the response
    392   if (*(incoming_pdu->get_querycookie())==*(r_entry->qrc))
     388  if (*(incoming_pdu->get_querycookie())==*(r_entry->get_querycookie()))
    393389  {
    394390    DLog(param.name, "Query Cookie matched, accepting");
    395391
    396392    // delete the Query Cookie, it has fulfilled its purpose
    397     querycookie* tmp = r_entry->qrc;
    398     r_entry->qrc=NULL;
    399     if (tmp) delete tmp;
     393    r_entry->set_querycookie(NULL);
    400394
    401395    // delete old NLI use new one (new one is present due to checked precondition above)
    402     delete r_entry->nl;
    403     r_entry->nl= incoming_pdu->get_nli()->copy();
    404 
    405     r_entry->state=qn_established;             
    406     r_entry->rs_validity_time = gconf.getpar<uint32>(gistconf_rs_validity_time);
     396    r_entry->set_peer_nli(incoming_pdu->get_nli());
     397
     398    r_entry->set_state(qn_established);
     399    r_entry->set_rs_validity_time(gconf.getpar<uint32>(gistconf_rs_validity_time));
    407400
    408401    // create/reuse and store SII handle for this peer
    409     r_entry->sii_handle= param.rt.generate_sii_handle(r_entry->nl);
    410 
    411     DLog(param.name, "Installed NLI in routing state, SII handle = " << r_entry->sii_handle);
     402    r_entry->set_sii_handle(param.rt.generate_sii_handle(r_entry->get_peer_nli()));
     403
     404    DLog(param.name, "Installed NLI in routing state, SII handle = " << r_entry->get_sii_handle());
    412405
    413406    // set the timers
    414407               
    415408    // start Inactive_QNode timer on timer slot #1
    416     DLog(param.name, "Installed peer's RS-Validity time of " << r_entry->nl->get_rs_validity_time() << "ms");
     409    DLog(param.name, "Installed peer's RS-Validity time of " << r_entry->get_peer_nli()->get_rs_validity_time() << "ms");
    417410
    418411    // only start Inactive QNode if not running yet
    419     if (r_entry->timer_type != inactive_qnode)
    420       starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->rs_validity_time);
     412    if (r_entry->get_timer_type_1() != inactive_qnode)
     413            starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->get_rs_validity_time());
    421414               
    422415    // start Refresh_QNode timer on timer slot #2
    423     starttimer(r_key, r_entry, refresh_qnode, 0, randomized(r_entry->nl->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
     416    starttimer(r_key, r_entry, refresh_qnode, 0, randomized(r_entry->get_peer_nli()->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
    424417
    425418    // check whether other side did MA re-use and promoted our D-mode setup to C-mode
     
    428421      // if we requested D-Mode only, other side may decide to re-use existing MA
    429422      // we must update our routing entry accordingly in order to send back the right confirm
    430       if (r_entry->dmode)
     423      if (r_entry->is_dmode())
    431424      {
    432425        DLog(param.name, "We wanted D-mode setup, but other side did MA re-use, promoted to setting up in C-Mode");
    433426
    434         r_entry->dmode= false;
     427        r_entry->set_cmode();
    435428        // also upgrade to secure mode if MA was secured
    436         if (r_entry->secure == false)
    437           r_entry->secure= cap.is_secure(peer);
     429        if (r_entry->is_secure() == false)
     430                r_entry->set_secure(cap.is_secure(peer));
    438431      }     
    439432    }
    440433
    441     if (r_entry->dmode)
     434    if (r_entry->is_dmode())
    442435      DLog(param.name, "No request for Connection Mode was issued, setting up in D-Mode");
    443436
     
    450443    if (incoming_pdu->get_R())
    451444    {
    452       if (r_entry->dmode)
     445      if (r_entry->is_dmode())
    453446      {
    454447        DLog(param.name, "Sending back confirm in D-Mode");
     
    457450      else
    458451      {
    459         if (r_entry->secure)
     452        if (r_entry->is_secure())
    460453        {
    461454          DLog(param.name, "Sending back confirm in TLS secured C-Mode");
     
    523516  //*****************************************************************************
    524517               
    525   const peer_identity* mypi = r_entry->nl->get_pi();
     518  const peer_identity* mypi = r_entry->get_peer_nli()->get_pi();
    526519
    527520  const peer_identity* peerpi = incoming_pdu->get_nli()->get_pi();
     
    536529
    537530    // fill it with all the new data delivered from peer
    538     delete new_entry->nl;
    539     new_entry->nl = incoming_pdu->get_nli()->copy();
     531    new_entry->set_peer_nli(incoming_pdu->get_nli());
    540532   
    541533    // check for new SII handle and update it
    542     uint32 old_sii_handle=  new_entry->sii_handle;
    543     new_entry->sii_handle= param.rt.generate_sii_handle(new_entry->nl);
    544     if (new_entry->sii_handle == old_sii_handle)
    545     {
    546       ERRLog(param.name, "Consistency check failure for SII handle: I have a new peer, but SII handle did not change, it is still: " << new_entry->sii_handle);
    547     }
    548     DLog(param.name, color[red] << "New SII handle = " << new_entry->sii_handle << color[off]);
    549 
    550     if (incoming_pdu->get_stackconf()) new_entry->ma_hold_time = incoming_pdu->get_stackconf()->get_ma_hold_time();
     534    uint32 old_sii_handle=  new_entry->get_sii_handle();
     535    new_entry->set_sii_handle(param.rt.generate_sii_handle(new_entry->get_peer_nli()));
     536    if (new_entry->get_sii_handle() == old_sii_handle)
     537    {
     538            ERRLog(param.name, "Consistency check failure for SII handle: I have a new peer, but SII handle did not change, it is still: " << new_entry->get_sii_handle());
     539    }
     540    DLog(param.name, color[red] << "New SII handle = " << new_entry->get_sii_handle() << color[off]);
     541
     542    if (incoming_pdu->get_stackconf())
     543            new_entry->set_ma_hold_time(incoming_pdu->get_stackconf()->get_ma_hold_time());
    551544                 
    552545    // look for inverse direction
     
    580573  if (incoming_pdu->get_R())
    581574  {
    582     if (r_entry->dmode)
     575    if (r_entry->is_dmode())
    583576    {
    584577      DLog(param.name, "Sending back confirm in D-Mode");
     
    587580    else
    588581    {
    589       if (r_entry->secure)
     582      if (r_entry->is_secure())
    590583      {
    591584        send_confirm_cmode(incoming_pdu, r_key, r_entry);
     
    608601  // freshen NLI
    609602  if (!rerouted)
    610     r_entry->nl = incoming_pdu->get_nli()->copy();
    611 
    612   DLog(param.name, "Installed peer's RS-Validity time of " << r_entry->nl->get_rs_validity_time() <<"ms");
     603          r_entry->set_peer_nli(incoming_pdu->get_nli());
     604
     605  DLog(param.name, "Installed peer's RS-Validity time of " << r_entry->get_peer_nli()->get_rs_validity_time() <<"ms");
    613606
    614607  // (re)Start refresh_QNode timer
    615   starttimer(r_key, r_entry, refresh_qnode, 0, randomized(r_entry->nl->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
     608  starttimer(r_key, r_entry, refresh_qnode, 0, randomized(r_entry->get_peer_nli()->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
    616609
    617610  // Start inactive_QNode timer if not running
    618   if (r_entry->timer_type != inactive_qnode)
    619     starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->rs_validity_time);
    620 
    621   r_entry->state = qn_established;
     611  if (r_entry->get_timer_type_1() != inactive_qnode)
     612          starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->get_rs_validity_time());
     613
     614  r_entry->set_state(qn_established);
    622615
    623616  networknotification(r_key, r_entry, APIMsg::route_changed_status_good, rerouted);
     
    638631
    639632    DLog(param.name, "Established, but however sending back a GIST Confirm, as it was requested");
    640     if (r_entry->dmode) {
     633    if (r_entry->is_dmode()) {
    641634      send_confirm_dmode(incoming_pdu, r_key, r_entry);
    642635    } else {
     
    647640           
    648641  // start Refresh_QNode again
    649   starttimer(r_key, r_entry, refresh_qnode, 0, randomized(r_entry->nl->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
     642  starttimer(r_key, r_entry, refresh_qnode, 0, randomized(r_entry->get_peer_nli()->get_rs_validity_time(), gconf.getpar<float>(gistconf_retryfactor)));
    650643
    651644  // Inactive_QNode should be running already (was probably restarted by incoming piggybacked NSLP data earlier)
    652   if (r_entry->timer_type != inactive_qnode)
     645  if (r_entry->get_timer_type_1() != inactive_qnode)
    653646  {
    654647    ERRCLog(param.name, "Response in established: expected that " << timername(inactive_qnode) << " timer is already running - internal error");
    655     //starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->rs_validity_time);
     648    //starttimer(r_key, r_entry, inactive_qnode, 0, r_entry->get_rs_validity_time());
    656649  }
    657650
     
    661654  // update RS_Validity Time (we update the whole NLI)
    662655  if (incoming_pdu->get_nli()) {
    663     delete r_entry->nl;
    664     r_entry->nl=NULL;
    665     r_entry->nl = incoming_pdu->get_nli()->copy();
     656    r_entry->set_peer_nli(incoming_pdu->get_nli());
    666657  }
    667658}
     
    716707  appladdress* target= new appladdress;
    717708  target->set_port(gconf.getpar<uint16>(gistconf_udpport));
    718   if (!r_entry->nl) {
     709  if (!r_entry->get_peer_nli()) {
    719710    ERRCLog(param.name, "No NLI saved locally for this peer. Cannot proceed.");
    720711    return;
    721712  }
    722   target->set_ip(r_entry->nl->get_if_address());
     713  target->set_ip(r_entry->get_peer_nli()->get_if_address());
    723714  target->set_protocol(param.udp);
    724715
     
    730721  // construct CONFIRM with copies of objects in response, but no stackprop and NLI of US
    731722   
    732   nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry->nl->get_if_address(), r_entry);
    733   mynli->set_ip_ttl(r_entry->ip_ttl);
     723  nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry->get_peer_nli()->get_if_address(), r_entry);
     724  mynli->set_ip_ttl(r_entry->get_ip_ttl());
    734725
    735726
     
    748739  // put into signaling message
    749740  sigmsg->set_req(target, conf);
    750   sigmsg->set_local_addr(r_entry->local_src->copy());
     741  sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    751742  sigmsg->send_or_delete();
    752743}
     
    769760  // construct signaling message
    770761  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
    771   sigmsg->set_local_addr(r_entry->local_src->copy());
     762  sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    772763
    773764  appladdress* target = NULL;
     
    775766  appladdress*  errortarget= new appladdress;
    776767  errortarget->set_port( gconf.getpar<uint16>(gistconf_udpport) );
    777   if (!r_entry->nl) {
     768  if (!r_entry->get_peer_nli()) {
    778769    ERRCLog(param.name, "No NLI saved locally for this peer. Cannot proceed.");
    779770    return false;
    780771  }
    781   errortarget->set_ip(r_entry->nl->get_if_address());
     772  errortarget->set_ip(r_entry->get_peer_nli()->get_if_address());
    782773  errortarget->set_protocol(param.udp);
    783774
     
    787778  {
    788779    // construct target address
    789     target= cap.get_address(pdu->get_stackprop(), pdu->get_stackconf(), new nli(*r_entry->nl), r_entry->secure);
     780    target= cap.get_address(pdu->get_stackprop(), pdu->get_stackconf(), r_entry->get_peer_nli()->copy(), r_entry->is_secure());
    790781    if (target == NULL || target->get_port() == 0)
    791782    {
     
    798789    // no stack proposal and stuff, this could be the case for receiving responses sent over existing MAs for MA re-use
    799790    // state may already have been changed to established before calling this method
    800     if (!r_entry->dmode && (r_entry->state == qn_awaiting_response || r_entry->state == qn_awaiting_refresh || r_entry->state == qn_established) )
     791    if (r_entry->is_cmode() &&
     792        (r_entry->get_state() == qn_awaiting_response || r_entry->get_state() == qn_awaiting_refresh ||
     793         r_entry->get_state() == qn_established) )
    801794    {
    802795      // try ma re-use
    803       target= param.rt.lookup_ma_peeraddress(r_entry->nl);
     796      target= param.rt.lookup_ma_peeraddress(r_entry->get_peer_nli());
    804797      if (target == NULL)
    805798      {
     
    847840  // if no stack conf available, we should have an MA anyway
    848841  if (pdu->get_stackconf())
    849     param.rt.add_ma(new nli(*(r_entry->nl)), *target, pdu->get_stackconf()->get_ma_hold_time(),false);
     842          param.rt.add_ma(r_entry->get_peer_nli()->copy(), *target, pdu->get_stackconf()->get_ma_hold_time(),false);
    850843
    851844  // construct CONFIRM with copies of objects in response, but no data and NLI of US
    852   nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry->nl->get_if_address(), r_entry);
    853   mynli->set_ip_ttl(r_entry->ip_ttl);
     845  nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry->get_peer_nli()->get_if_address(), r_entry);
     846  mynli->set_ip_ttl(r_entry->get_ip_ttl());
    854847
    855848  // construct an empty ma_protocol_option object, only holding MA_HOLD_TIME, repetition for late state installation on peer
     
    906899  if (r_entry)
    907900  {
    908     if (r_entry->timer_type != inactive_qnode) {
    909       DLog(param.name, "Deliberately stopped timer, ignoring");
    910       param.rt.unlock(r_key);
    911       return;
    912     }
    913 
    914     if (r_entry->timer_id == timermsg->get_id())
    915     {
    916       DLog(param.name, "Timer slot 1, timer is valid, id: " << timermsg->get_id());
     901          if (r_entry->get_timer_type_1() != inactive_qnode) {
     902                  DLog(param.name, "Deliberately stopped timer, ignoring");
     903                  param.rt.unlock(r_key);
     904                  return;
     905          }
     906
     907          if (r_entry->get_timer_id_1() == timermsg->get_id())
     908          {
     909                  DLog(param.name, "Timer slot 1, timer is valid, id: " << timermsg->get_id());
    917910       
    918       // inactive_qnode timer is to be applied from all states
     911                  // inactive_qnode timer is to be applied from all states
     912                 
     913                  r_entry->set_state(dead);
     914                  EVLog(param.name, color[magenta] << "InactiveQNode timer went off" << color[off]);
     915                  // notify about Routing State down
     916                  // Notify NSLP about Routing State Change
    919917           
    920       r_entry->state=dead;
    921       EVLog(param.name, color[magenta] << "InactiveQNode timer went off" << color[off]);
    922       // notify about Routing State down
    923       // Notify NSLP about Routing State Change
    924            
    925       networknotification(r_key, r_entry, APIMsg::route_changed_status_bad, true);
     918                  networknotification(r_key, r_entry, APIMsg::route_changed_status_bad, true);
    926919     
    927       // we should stop any running timers on slot 2, refresh qnode
    928       // slot 3 should not be running at this point in time!
    929       canceltimers(r_entry);
    930 
    931       param.rt.delete_entry(r_key);
    932       r_key= 0;
    933     }
    934     if (r_key) param.rt.unlock(r_key);
     920                  // we should stop any running timers on slot 2, refresh qnode
     921                  // slot 3 should not be running at this point in time!
     922                  canceltimers(r_entry);
     923
     924                  param.rt.delete_entry(r_key);
     925                  r_key= 0;
     926          }
     927          if (r_key) param.rt.unlock(r_key);
    935928  }
    936929}
     
    951944  if (r_entry)
    952945  {
    953     if (r_entry->timer_type_2 != noresponse) {
     946    if (r_entry->get_timer_type_2() != noresponse) {
    954947      DLog(param.name, "Deliberately stopped timer, ignoring");
    955948      param.rt.unlock(r_key);
     
    957950    }
    958951
    959     if (r_entry->timer_id_2 == timermsg->get_id())
     952    if (r_entry->get_timer_id_2() == timermsg->get_id())
    960953    {
    961954      DLog(param.name, "Timer slot 2, timer is valid, id: " << timermsg->get_id());
     
    965958      // NoResponse timer retransmits Queries until state changes to rn_established and timer is stopped
    966959      if (! r_entry->retry_limit_reached() &&
    967           (param.addresses.addr_is(*r_entry->local_src, AddressList::LocalAddr_P) ||
    968           param.addresses.addr_is(*r_entry->local_src, AddressList::HomeAddr_P)))
    969       {
    970         if (r_entry->dmode) {
     960          (param.addresses.addr_is(*r_entry->get_local_src(), AddressList::LocalAddr_P) ||
     961           param.addresses.addr_is(*r_entry->get_local_src(), AddressList::HomeAddr_P)))
     962      {
     963        if (r_entry->is_dmode()) {
    971964          send_query(NULL, r_key, r_entry);
    972965        } else {
     
    986979        // leave NoResponse timer stopped
    987980               
    988         r_entry->state=dead;
     981        r_entry->set_state(dead);
    989982               
    990983        // clear data for repeats
    991         if (r_entry->mod_data) {
    992           nslpdata* tmp = r_entry->mod_data;
    993           r_entry->mod_data = NULL;
    994           delete tmp;
    995         }
     984        r_entry->set_mod_data(NULL);
    996985               
    997986        // notify about Routing State INVALID (was never UP!)
     
    1001990               
    1002991        // notify about lost Message because no node found (handshake went wrong)
    1003         messagestatus(r_key, r_entry, r_entry->msg_id, APIMsg::error_msg_node_not_found);
     992        messagestatus(r_key, r_entry, r_entry->get_msg_id(), APIMsg::error_msg_node_not_found);
    1004993                               
    1005994        // notify about inverse direction Routing State 'tentative'
     
    10451034  if (r_entry)
    10461035  {
    1047     if (r_entry->timer_type_2 != refresh_qnode) {
     1036    if (r_entry->get_timer_type_2() != refresh_qnode) {
    10481037      DLog(param.name, "Deliberately stopped timer, ignoring");
    10491038      param.rt.unlock(r_key);
     
    10511040    }
    10521041
    1053     if (!(param.addresses.addr_is(*r_entry->local_src, AddressList::LocalAddr_P) ||
    1054         param.addresses.addr_is(*r_entry->local_src, AddressList::HomeAddr_P))) {
     1042    if (!(param.addresses.addr_is(*r_entry->get_local_src(), AddressList::LocalAddr_P) ||
     1043          param.addresses.addr_is(*r_entry->get_local_src(), AddressList::HomeAddr_P))) {
    10551044      DLog(param.name, "Local Address no longer owned - let it die!");
    10561045      param.rt.unlock(r_key);
     
    10581047    }
    10591048
    1060     if (r_entry->timer_id_2 == timermsg->get_id())
     1049    if (r_entry->get_timer_id_2() == timermsg->get_id())
    10611050    {
    10621051      DLog(param.name, "Timer slot 2, timer is valid, id: " << timermsg->get_id());
     
    10671056
    10681057      // delete query cookie before initiating the Query Sequence ->new cookies are used each handshake
    1069       if (r_entry->qrc) delete r_entry->qrc;
     1058      r_entry->set_querycookie(NULL);
    10701059           
    10711060      // send Query
    1072       if (r_entry->dmode)
     1061      if (r_entry->is_dmode())
    10731062      {
    10741063        send_query(NULL, r_key, r_entry);
     
    10801069           
    10811070      // transition to qn_awaiting_refresh
    1082       r_entry->state= qn_awaiting_refresh;
     1071      r_entry->set_state(qn_awaiting_refresh);
    10831072           
    10841073      // kickstart NoResponse timer
  • ntlp/trunk/src/ntlp_statemodule_responder.cpp

    r4226 r4231  
    9090
    9191    // NTO contains the original (local to the Querier) MRI, NLI and SCD
    92     r_entry->nattrav= nattrav->copy();
     92    r_entry->set_nattraversal(nattrav);
    9393  }
    9494       
    9595  // set our RS_Validity time
    96   r_entry->rs_validity_time = gconf.getpar<uint32>(gistconf_rs_validity_time);
     96  r_entry->set_rs_validity_time(gconf.getpar<uint32>(gistconf_rs_validity_time));
    9797         
    9898  // save Query Cookie for Response retries
    99   r_entry->qrc=new querycookie(*(query_pdu->get_querycookie()));
     99  r_entry->set_querycookie(query_pdu->get_querycookie());
    100100
    101101  nli* query_nli= query_pdu->get_nli();
     
    103103  { // use NLI from the PDU
    104104    // save NLI
    105     r_entry->nl= new nli(*query_nli);
     105    r_entry->set_peer_nli(query_nli);
    106106    // if this Query traversed a GIST-aware NAT we have a translated NLI to save
    107     if (r_entry->nattrav)
    108             r_entry->translated_nli= new nli(*query_nli);
     107    if (r_entry->get_nattraversal())
     108            r_entry->set_translated_nli(query_nli);
    109109  }
    110110
    111111  // check whether this is our own query by comparing the Peer ID
    112   if (r_entry->nl)
    113   {
    114           const peer_identity* pid= r_entry->nl->get_pi();
     112  if (r_entry->get_peer_nli())
     113  {
     114          const peer_identity* pid= r_entry->get_peer_nli()->get_pi();
    115115          if ( pid && (*pid == *(param.nli_tmpl.get_pi())) )
    116116          { // peer id from query nli is the same as ours, this is usually an error
     
    123123
    124124  // SII handle in the entry
    125   r_entry->sii_handle= param.rt.generate_sii_handle(r_entry->nl);
    126   DLog(param.name, "Saved NLI, SII handle = " << r_entry->sii_handle);
     125  r_entry->set_sii_handle(param.rt.generate_sii_handle(r_entry->get_peer_nli()));
     126  DLog(param.name, "Saved NLI, SII handle = " << r_entry->get_sii_handle());
    127127 
    128128  // Here we decide on C/D-Mode and security, this depends on the presence of a stack proposal
     
    132132  if (remote_stackprop)
    133133  {
    134     r_entry->dmode= false;
    135     // secure MA requested?
    136     // currently we check this by creating an own proposal consisting of only secure protocols
    137     // and check whether the querier proposal could be accepted
    138     r_entry->secure= cap.accept_proposal(remote_stackprop, true);
     134          r_entry->set_cmode();
     135          // secure MA requested?
     136          // currently we check this by creating an own proposal consisting of only secure protocols
     137          // and check whether the querier proposal could be accepted
     138          r_entry->set_secure(cap.accept_proposal(remote_stackprop, true));
    139139  }
    140140  else
    141141  {
    142     r_entry->dmode= true;
    143     r_entry->secure= false; // no security without stack proposal
    144   }
    145 
    146   DLog(param.name, "Requested properties of transfer: " << (r_entry->dmode ? "D-Mode" : "C-Mode") << ", " << (r_entry->secure ? "secure" : "non-secure"));
     142          r_entry->set_dmode();
     143          r_entry->set_secure(false); // no security without stack proposal
     144  }
     145
     146  DLog(param.name, "Requested properties of transfer: " << (r_entry->is_dmode() ? "D-Mode" : "C-Mode") << ", " << (r_entry->is_secure() ? "secure" : "non-secure"));
    147147
    148148  if (query_pdu->get_stackconf())
     
    158158    }
    159159    else
    160       r_entry->ma_hold_time= query_pdu->get_stackconf()->get_ma_hold_time();
    161 
    162     DLog(param.name, "Saved MA Hold time: " << r_entry->ma_hold_time);
     160            r_entry->set_ma_hold_time(query_pdu->get_stackconf()->get_ma_hold_time());
     161
     162    DLog(param.name, "Saved MA Hold time: " << r_entry->get_ma_hold_time());
    163163  }
    164164  else
     
    178178 
    179179  // fill temporary storage items
    180   r_entry->tmppdu = query_pdu->copy();
    181   r_entry->tmppeer = peer->copy();
     180  r_entry->set_tmppdu(query_pdu);
     181  r_entry->set_tmppeer(peer);
    182182
    183183  // remember incoming interface for query
     
    186186 
    187187  // set up temporary state
    188   r_entry->state = rn_querynslp;
     188  r_entry->set_state(rn_querynslp);
    189189 
    190190  param.rt.add(r_key, r_entry);
     
    205205{
    206206  // stop Expire_RNode timer
    207   r_entry->timer_type= none;
     207  r_entry->set_timer_type_1(none);
    208208                   
    209209  // save Query Cookie
    210   r_entry->qrc=new querycookie(*(query_pdu->get_querycookie()));
     210  r_entry->set_querycookie(query_pdu->get_querycookie());
    211211
    212212  const stackprop* remote_stackprop= query_pdu->get_stackprop();
     
    214214  if (remote_stackprop)
    215215  {
    216     r_entry->sp = remote_stackprop->copy();
     216    r_entry->set_sp(remote_stackprop);
    217217   
    218     if (r_entry->dmode)
     218    if (r_entry->is_dmode())
    219219    {
    220220      EVLog(param.name, "Querier requested to promote from D-Mode to C-Mode");
    221       r_entry->dmode= false;
     221      r_entry->set_cmode();
    222222    }
    223223    // secure MA requested?
    224224    // currently we check this by creating an own proposal consisting of only secure protocols
    225225    // and check whether the querier proposal could be accepted
    226     if (!r_entry->secure)
    227     {
    228       if ( (r_entry->secure= cap.accept_proposal(remote_stackprop, true)) == true)
     226    if (!r_entry->is_secure())
     227    {
     228      r_entry->set_secure(cap.accept_proposal(remote_stackprop, true));
     229      if ( r_entry->is_secure() )
    229230      { // now security requested
    230231        EVLog(param.name, "Querier requested to promote to secure MA");
     
    235236  // save Stackconf
    236237  if (query_pdu->get_stackconf())
    237     r_entry->sc = query_pdu->get_stackconf()->copy();
     238          r_entry->set_sc(query_pdu->get_stackconf());
    238239  else
    239240  {
     
    257258    starttimer(r_key, r_entry, noconfirm, 0, r_entry->reset_retry_timeout());
    258259             
    259     r_entry->state=rn_awaiting_refresh;
     260    r_entry->set_state(rn_awaiting_refresh);
    260261  }
    261262  else
     
    265266    send_response(query_pdu, r_key, r_entry, peer);
    266267
    267     starttimer(r_key, r_entry, expire_rnode, 0, r_entry->rs_validity_time);
     268    starttimer(r_key, r_entry, expire_rnode, 0, r_entry->get_rs_validity_time());
    268269             
    269     r_entry->state=rn_established;
     270    r_entry->set_state(rn_established);
    270271  }
    271272}
     
    279280  // stop Expire_RNode timer
    280281
    281   r_entry->timer_type= none;
     282  r_entry->set_timer_type_1(none);
    282283                   
    283284  // save Query Cookie
    284   r_entry->qrc= new querycookie(*(query_pdu->get_querycookie()));
     285  r_entry->set_querycookie(query_pdu->get_querycookie());
    285286                   
    286287  // save newer Stackprop
    287288  if (query_pdu->get_stackprop())
    288     r_entry->sp = query_pdu->get_stackprop()->copy();
     289          r_entry->set_sp(query_pdu->get_stackprop());
    289290                   
    290291  // save newer Stackconf
    291292  if (query_pdu->get_stackconf()) 
    292     r_entry->sc = query_pdu->get_stackconf()->copy();
     293          r_entry->set_sc(query_pdu->get_stackconf());
    293294                   
    294   DLog(param.name, "Query arrived when waiting for " <<  ((r_entry->state==rn_awaiting_refresh) ? "refresh" : ((r_entry->state==rn_awaiting_confirm) ?  "confirm" : (r_entry->get_state_name()))) << ", requesting GIST Confirm");
     295  DLog(param.name, "Query arrived when waiting for " <<  ((r_entry->get_state()==rn_awaiting_refresh) ? "refresh" : ((r_entry->get_state()==rn_awaiting_confirm) ?  "confirm" : (r_entry->get_state_name()))) << ", requesting GIST Confirm");
    295296  send_response(query_pdu, r_key, r_entry, peer, true);
    296297
     
    298299  starttimer(r_key, r_entry, noconfirm, 0, r_entry->reset_retry_timeout());
    299300
    300   if (r_entry->state == rn_awaiting_refresh || r_entry->state == rn_awaiting_confirm)
     301  if (r_entry->get_state() == rn_awaiting_refresh || r_entry->get_state() == rn_awaiting_confirm)
    301302  {
    302303    DLog(param.name, "staying in state " << r_entry->get_state_name());
     
    351352 
    352353
    353           if (translated_nli && r_entry->translated_nli && (*translated_nli != *(r_entry->translated_nli)))
     354          if (translated_nli && r_entry->get_translated_nli() && (*translated_nli != *(r_entry->get_translated_nli())))
    354355          {
    355356                  WLog(param.name,"Translated NLI differs between initial query and routing state entry");
     
    371372        // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    372373        SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    373         sigmsg->set_local_addr(r_entry->local_src->copy());
     374        sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    374375        sigmsg->set_trm(peer->copy());     
    375376        sigmsg->send_or_delete();
     
    391392        if (secure_ma_requested)
    392393        {
    393           r_entry->secure= true;
     394                r_entry->set_secure(true);
    394395        }
    395396
    396397        // since either no secure MA was requested or at least a stack proposal was present,
    397398        // we have reliable MA at least
    398         r_entry->dmode= false;
     399        r_entry->set_cmode();
    399400      } // end proposal accepted
    400401    } // endif echoed stack proposal present
    401402
    402403    // Here we verify C/D-Mode and security requirements
    403     if ( r_entry->secure && cap.is_secure(peer)==false )
     404    if ( r_entry->is_secure() && cap.is_secure(peer)==false )
    404405    {
    405406      // Confirm came over non-secure connection
     
    408409      // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    409410      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    410       sigmsg->set_local_addr(r_entry->local_src->copy());
     411      sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    411412      sigmsg->set_trm(peer->copy());       
    412413      sigmsg->send_or_delete();
     
    428429        return;
    429430      }
    430       nli* newnli = cnfpdu->get_nli()->copy();
    431       delete r_entry->nl;
    432       r_entry->nl= newnli;
     431      r_entry->set_peer_nli(cnfpdu->get_nli());
    433432
    434433      // check for new SII handle and update it
    435       uint32 old_sii_handle=  r_entry->sii_handle;
    436       r_entry->sii_handle= param.rt.generate_sii_handle(newnli);
    437       if (r_entry->sii_handle != old_sii_handle)
     434      uint32 old_sii_handle=  r_entry->get_sii_handle();
     435      r_entry->set_sii_handle(param.rt.generate_sii_handle(cnfpdu->get_nli()));
     436      if (r_entry->get_sii_handle() != old_sii_handle)
    438437      {
    439438        ERRLog(param.name, "Consistency check failure for SII handle: SII handle did change for Confirm old: "
    440                << old_sii_handle << " new: " << r_entry->sii_handle);
     439               << old_sii_handle << " new: " << r_entry->get_sii_handle());
    441440      }
    442441    }
     
    453452   
    454453    // disposal of saved responder data
    455     nslpdata* moddata = NULL;
    456     moddata = r_entry->mod_data;
    457     r_entry->mod_data = NULL;
    458     if (moddata) delete moddata;
     454    r_entry->set_mod_data(NULL);
    459455   
    460456    // set up C-Mode if proposal came via an MA (C-Mode setup requires that confirm is sent over MA)
    461     if (!r_entry->dmode)
     457    if (r_entry->is_cmode())
    462458    {
    463459      // we do accept if stackprop is contained and is acceptable
     
    466462        if (cap.accept_proposal(echoed_resp_proposal))
    467463        {
    468           param.rt.add_ma(r_entry->nl->copy(), *peer, r_entry->ma_hold_time, true);
    469           DLog(param.name, color[green] << "State setup in C-Mode");
    470           if (r_entry->secure) DLog(param.name, "Security is set for this connection");
     464                param.rt.add_ma(r_entry->get_peer_nli()->copy(), *peer, r_entry->get_ma_hold_time(), true);
     465                DLog(param.name, color[green] << "State setup in C-Mode");
     466                if (r_entry->is_secure()) DLog(param.name, "Security is set for this connection");
    471467        }
    472468        else
     
    480476          // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    481477          SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    482           sigmsg->set_local_addr(r_entry->local_src->copy());
     478          sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    483479          sigmsg->set_trm(peer->copy());           
    484480          sigmsg->send_or_delete();
     
    497493    // stop NoConfirm timer, restart it as expire_rnode timer (implicit, they are running on the same slot)
    498494    // start Expire_RNode timer
    499     starttimer(r_key, r_entry, expire_rnode, 0, r_entry->rs_validity_time);
     495          starttimer(r_key, r_entry, expire_rnode, 0, r_entry->get_rs_validity_time());
    500496
    501497    // put in state "rn_established"
    502498    DLog(param.name, color[green] << "State installed: rn_awaiting_confirm -> rn_established");
    503499   
    504     r_entry->state= rn_established;
     500    r_entry->set_state(rn_established);
    505501   
    506502    // notify application about this event
     
    582578  if (translated_nli)
    583579  {       // please note that translated_nli will be freed by rentry destructor
    584           r_entry->translated_nli= peer_nli;
     580          r_entry->set_translated_nli(peer_nli);
    585581  }
    586582
     
    599595      return;
    600596    }
    601     r_entry->nl= cnfnli->copy();
     597    r_entry->set_peer_nli(cnfnli);
    602598
    603599    // install SII handle
    604     r_entry->sii_handle= param.rt.generate_sii_handle(cnfnli);
    605     DLog(param.name, "SII handle = " << r_entry->sii_handle);
     600    r_entry->set_sii_handle(param.rt.generate_sii_handle(cnfnli));
     601    DLog(param.name, "SII handle = " << r_entry->get_sii_handle());
    606602
    607603    // now check for MA re-use.
     
    622618
    623619      // if this confirm came via an existing MA, it's a C-mode setup
    624       r_entry->dmode= false;
     620      r_entry->set_cmode();
    625621
    626622      // must set MA hold time to meaningful value
    627       r_entry->ma_hold_time= ma_p->get_ma_hold_time();
     623      r_entry->set_ma_hold_time(ma_p->get_ma_hold_time());
    628624    }
    629625  }
     
    648644  if (responder_cookie->get_transparent_data())
    649645  {
    650           r_entry->nattrav= responder_cookie->get_nto(peer_nli->get_serialized_size(IE::protocol_v1));
     646          r_entry->set_nattraversal(responder_cookie->get_nto(peer_nli->get_serialized_size(IE::protocol_v1)));
    651647  }
    652648
    653649  // set our RS_Validity time
    654   r_entry->rs_validity_time = gconf.getpar<uint32>(gistconf_rs_validity_time);
     650  r_entry->set_rs_validity_time(gconf.getpar<uint32>(gistconf_rs_validity_time));
    655651
    656652  // what we want is in the echoed response stack proposal
     
    673669      // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    674670      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    675       sigmsg->set_local_addr(r_entry->local_src->copy());
     671      sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    676672      sigmsg->set_trm(peer->copy());       
    677673      sigmsg->send_or_delete();
     
    693689      if (secure_ma_requested)
    694690      {
    695         r_entry->secure= true;
     691              r_entry->set_secure();
    696692      }
    697693
    698694      // since either no secure MA was requested or at least a stack proposal was present,
    699695      // we have reliable MA at least
    700       r_entry->dmode= false;
     696      r_entry->set_cmode();
    701697    } // end proposal accepted
    702698  } // endif echoed stack proposal present
    703699
    704700  // Here we verify C/D-Mode and security requirements
    705   if ( r_entry->secure && cap.is_secure(peer)==false )
     701  if ( r_entry->is_secure() && cap.is_secure(peer)==false )
    706702  {
    707703    // Confirm came over non-secure connection
     
    710706    // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    711707    SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    712     sigmsg->set_local_addr(r_entry->local_src->copy());
     708    sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    713709    sigmsg->set_trm(peer->copy());         
    714710    sigmsg->send_or_delete();
     
    720716  // we need also to consider the case were the other side
    721717  // upgraded the connection to be secure or reliable
    722   if ( r_entry->secure == false && cap.is_secure(peer) )
    723     r_entry->secure= true;
     718  if ( r_entry->is_secure() == false && cap.is_secure(peer) )
     719          r_entry->set_secure();
    724720
    725721  // if C-Mode required, the Confirm must have been sent over the MA
    726722  // if not, we can only ignore 
    727   if ( r_entry->dmode == false )
     723  if ( r_entry->is_cmode() )
    728724  {
    729725    if (!cap.is_reliable(peer))
     
    761757      else
    762758      {
    763         r_entry->ma_hold_time= sc->get_ma_hold_time();
     759              r_entry->set_ma_hold_time(sc->get_ma_hold_time());
    764760      }
    765761    }
     
    768764
    769765    // establish MA
    770     param.rt.add_ma(new nli(*r_entry->nl), *peer, r_entry->ma_hold_time, true);
     766    param.rt.add_ma(r_entry->get_peer_nli()->copy(), *peer, r_entry->get_ma_hold_time(), true);
    771767
    772768    DLog(param.name, "State setup: C-Mode");
     
    774770  else
    775771  { // required if not in D-Mode and no MA re-use: peer must repeat ma_hold_time in Confirm
    776     if (!r_entry->dmode && ma_reuse == false)
     772          if (r_entry->is_cmode() && ma_reuse == false)
    777773    {
    778774      ERRCLog(param.name, "Encountered GIST protocol error: GIST Confirm lacks a stack configuration data object! - State NOT installed");
     
    790786  // put in state "rn_established"
    791787  DLog(param.name, "State " << color[green] << "established" << color[off]);
    792   r_entry->state=rn_established;
     788  r_entry->set_state(rn_established);
    793789  // stop NoConfirm Timer (without state, there is no timer running...)
    794790                   
    795791  // start Expire_RNode timer
    796   starttimer(r_key, r_entry, expire_rnode, 0, r_entry->rs_validity_time);
     792  starttimer(r_key, r_entry, expire_rnode, 0, r_entry->get_rs_validity_time());
    797793
    798794  EVLog(param.name, "Delivering Payload to NSLP");
     
    871867                                   
    872868  // *****************+ Detect Routing Change +*************************
    873   const peer_identity* mypi = r_entry->nl->get_pi();
     869  const peer_identity* mypi = r_entry->get_peer_nli()->get_pi();
    874870  const peer_identity* peerpi = cnfpdu->get_nli()->get_pi();
    875871  assert(mypi!=NULL);
     
    889885    const hostaddress *src = dynamic_cast<const hostaddress *>(own_addr);
    890886    if (src->is_ip_unspec()) {
    891       DLog(param.name, "Couldn't determine own address on receive - using reverse lookup");
     887      DLog(param.name, "Couldn't determine own address on receipt - using reverse path forwarding lookup");
    892888      uint32_t pref = IPV6_PREFER_SRC_COA;
    893889      src = param.addresses.get_src_addr(*(dynamic_cast<const hostaddress *>(peer)), &pref);
    894890    }
    895     r_entry->set_local_src(*src->copy());
     891    r_entry->set_local_src(*src);
    896892
    897893    // match it with all the new data delivered from peer
    898     delete new_entry->nl;
    899     new_entry->nl = cnfpdu->get_nli()->copy();
     894    new_entry->set_peer_nli(cnfpdu->get_nli());
    900895
    901896    // check for new SII handle and update it
    902     uint32 old_sii_handle=  r_entry->sii_handle;
    903     new_entry->sii_handle= param.rt.generate_sii_handle(new_entry->nl);
    904     if (new_entry->sii_handle == old_sii_handle)
    905     {
    906       ERRLog(param.name, "Consistency check failure for SII handle: I have a new peer, but SII handle did not change, it is still: " << new_entry->sii_handle);
     897    uint32 old_sii_handle=  r_entry->get_sii_handle();
     898    new_entry->set_sii_handle(param.rt.generate_sii_handle(new_entry->get_peer_nli()));
     899    if (new_entry->get_sii_handle() == old_sii_handle)
     900    {
     901            ERRLog(param.name, "Consistency check failure for SII handle: I have a new peer, but SII handle did not change, it is still: " << new_entry->get_sii_handle());
    907902    }
    908903
     
    911906      if (cnfpdu->get_stackconf()->get_ma_hold_time() == 0)
    912907      {
    913         ERRCLog(param.name, "Tried to install an MA with peer MA Hold time of ZERO");
    914         // send back an error indicating an invalid MA_Hold_Time
    915         senderror(cnfpdu, peer, GIST_Error::error_gist_value_not_supported, known_ntlp_object::StackConfiguration, cnfpdu->get_stackconf());
    916         // use old MA hold time entry
    917         new_entry->ma_hold_time= r_entry->ma_hold_time;
     908              ERRCLog(param.name, "Tried to install an MA with peer MA Hold time of ZERO");
     909              // send back an error indicating an invalid MA_Hold_Time
     910              senderror(cnfpdu, peer, GIST_Error::error_gist_value_not_supported, known_ntlp_object::StackConfiguration, cnfpdu->get_stackconf());
     911              // use old MA hold time entry
     912              new_entry->set_ma_hold_time(r_entry->get_ma_hold_time());
    918913      }
    919914      else
    920         new_entry->ma_hold_time= cnfpdu->get_stackconf()->get_ma_hold_time();
     915              new_entry->set_ma_hold_time(cnfpdu->get_stackconf()->get_ma_hold_time());
    921916    }
    922917                       
     
    934929                   
    935930  // refresh for C-Mode
    936   if (!r_entry->dmode)
     931  if (r_entry->is_cmode())
    937932  {
    938933    // stack configuration data MUST be present for the very first Confirm, but is optional otherwise
     
    946941      }
    947942      else
    948         r_entry->ma_hold_time= cnfpdu->get_stackconf()->get_ma_hold_time();
    949 
    950       DLog(param.name, "Saved peer MA Hold time of " << r_entry->ma_hold_time << "ms");
     943              r_entry->set_ma_hold_time(cnfpdu->get_stackconf()->get_ma_hold_time());
     944
     945      DLog(param.name, "Saved peer MA Hold time of " << r_entry->get_ma_hold_time() << "ms");
    951946    } // endif stack configuration data present
    952947
    953948    // Here we verify C/D-Mode and security requirements
    954     if ( r_entry->secure && cap.is_secure(peer)==false )
     949    if ( r_entry->is_secure() && cap.is_secure(peer)==false )
    955950    {
    956951      // Confirm came over non-secure connection
     
    961956      // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    962957      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    963       sigmsg->set_local_addr(r_entry->local_src->copy());
     958      sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    964959      sigmsg->set_trm(peer->copy());       
    965960      sigmsg->send_or_delete();
     
    978973    }
    979974
    980     param.rt.add_ma(r_entry->nl->copy(), *peer, r_entry->ma_hold_time, true);
     975    param.rt.add_ma(r_entry->get_peer_nli()->copy(), *peer, r_entry->get_ma_hold_time(), true);
    981976    EVLog(param.name, color[green] << "State refresh in C-Mode" << color[off]);
    982977  }
     
    989984                   
    990985  // (re)start Expire_RNode timer
    991   starttimer(r_key, r_entry, expire_rnode, 0, r_entry->rs_validity_time);
     986  starttimer(r_key, r_entry, expire_rnode, 0, r_entry->get_rs_validity_time());
    992987                   
    993   r_entry->state=rn_established;
     988  r_entry->set_state(rn_established);
    994989}
    995990
     
    10241019
    10251020  // take stack proposal and stack proposal from routing entry if available
    1026   stackprop*       own_sp = r_entry->sp ? r_entry->sp->copy() : 0;
    1027   stack_conf_data* own_sc = r_entry->sc ? r_entry->sc->copy() : 0;
     1021  stackprop*       own_sp = r_entry->get_sp() ? r_entry->get_sp()->copy() : 0;
     1022  stack_conf_data* own_sc = r_entry->get_sc() ? r_entry->get_sc()->copy() : 0;
    10281023
    10291024  querycookie* qc = NULL;
     
    10331028  // we don't need a confirm only in case of a refresh
    10341029
    1035   bool requestconfirm= ( (r_entry->state == rn_established) && !gconf.getpar<bool>(gistconf_confirmrequired) ) ? false: true;
     1030  bool requestconfirm= ( (r_entry->get_state() == rn_established) && !gconf.getpar<bool>(gistconf_confirmrequired) ) ? false: true;
    10361031
    10371032  // if initial handshake and late state installation required, we need a confirm back
    1038   if ( (r_entry->state == rn_querynslp) && gconf.getpar<bool>(gistconf_latestate) )
     1033  if ( (r_entry->get_state() == rn_querynslp) && gconf.getpar<bool>(gistconf_latestate) )
    10391034    requestconfirm= true;
    10401035
     
    10621057    if (r_entry)
    10631058    {
    1064       delete r_entry->qrc;
    1065       r_entry->qrc= qc->copy();
     1059      r_entry->set_querycookie(qc);
    10661060    }
    10671061
     
    10981092
    10991093      // save them for retries
    1100       delete (r_entry->sp);
    1101       delete (r_entry->sc);
    1102      
    1103       r_entry->sp = own_sp->copy();
    1104       r_entry->sc = own_sc->copy();
     1094      r_entry->set_sp(own_sp);
     1095      r_entry->set_sc(own_sc);
    11051096     
    11061097      delete remote_proposal;
     
    11231114
    11241115    // take the query cookie we saved prior (this is a repetative response)
    1125     if (r_entry->qrc)
    1126       qc = r_entry->qrc->copy();
     1116    if (r_entry->get_querycookie())
     1117            qc = r_entry->get_querycookie()->copy();
    11271118  }
    11281119
     
    11311122
    11321123  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
    1133   sigmsg->set_local_addr(r_entry->local_src->copy());
     1124  sigmsg->set_local_addr(r_entry->get_local_src()->copy());
    11341125 
    11351126  // Generate our target address
     
    11541145  // and further refreshing queries carry untranslated addresses (local/internal addr)
    11551146  // for MA lookup we'll always use the untranslated NLI
    1156   nli* qnli= pdu ? pdu->get_nli() : r_entry->nl;
     1147  const nli* qnli= pdu ? pdu->get_nli() : r_entry->get_peer_nli();
    11571148
    11581149  if (qnli)
     
    11641155    if (ma_p)
    11651156    {
    1166       if (ma_p->is_secure() || r_entry->secure==false)
     1157      if (ma_p->is_secure() || r_entry->is_secure()==false)
    11671158      {
    11681159        response_dest= ma_p->get_peer_address().copy();
     
    11921183 
    11931184    // for NAT traversal scenario: must try translated NLI information first
    1194     if (r_entry->translated_nli)
     1185    if (r_entry->get_translated_nli())
    11951186    { // must sent back to NAT public address
    1196         response_dest->set_ip(r_entry->translated_nli->get_if_address());
     1187            response_dest->set_ip(r_entry->get_translated_nli()->get_if_address());
    11971188    }
    11981189    else
     
    12041195    else
    12051196    { // use what we already know from routing entry
    1206       if (r_entry->nl)
    1207         response_dest->set_ip(r_entry->nl->get_if_address());
     1197      if (r_entry->get_peer_nli())
     1198        response_dest->set_ip(r_entry->get_peer_nli()->get_if_address());
    12081199      else
    12091200      {
     
    12391230  // test if we have a saved nat traversal object (NTO)
    12401231  // we only need to send it back for an initial response, not for refreshing responses
    1241   nattraversal* nto = (r_entry->state == rn_querynslp) ? dynamic_cast<nattraversal*>(r_entry->nattrav) : NULL;
     1232  const nattraversal* nto = (r_entry->get_state() == rn_querynslp) ? dynamic_cast<const nattraversal*>(r_entry->get_nattraversal()) : NULL;
    12421233  NetMsg* ntobuf_p= NULL;
    12431234  // put NLI and NTO as transparent data into hash if present
     
    12761267 
    12771268  nslpdata* mydata = NULL;
    1278   if (r_entry->mod_data)
     1269  if (r_entry->get_mod_data())
    12791270  {
    12801271    if (gconf.getpar<bool>(gistconf_latestate) || (!gconf.getpar<bool>(gistconf_confirmrequired)))
    12811272    {
    12821273      DLog(param.name, "There will be no repetitions of this Response, cleaning replacement NSLP data");
    1283       delete (r_entry->mod_data);
    1284       r_entry->mod_data = NULL;
    1285 
    1286       mydata = NULL;
     1274      r_entry->set_mod_data(NULL);
    12871275    }
    12881276    else
    12891277    {
    1290       mydata=r_entry->mod_data->copy();
    1291       DLog(param.name, "Replacing original NSLP payload as required by NSLP");
     1278            mydata=r_entry->get_mod_data()->copy();
     1279            DLog(param.name, "Replacing original NSLP payload as required by NSLP");
    12921280    }
    12931281  }
     
    16151603  {
    16161604
    1617     if (r_entry->timer_type != expire_rnode) {
     1605    if (r_entry->get_timer_type_1() != expire_rnode) {
    16181606      DLog(param.name, "Deliberately stopped timer, ignoring");
    16191607      param.rt.unlock(r_key);
     
    16211609    }
    16221610
    1623     if (r_entry->timer_id == timermsg->get_id())
     1611    if (r_entry->get_timer_id_1() == timermsg->get_id())
    16241612    {
    16251613      DLog(param.name, "Timer slot 1, timer is valid, id: " << timermsg->get_id());
     
    16271615      // expire_rnode timer is to be applied from all states
    16281616      EVLog(param.name, color[magenta] << "ExpireRNode timer went off" << color[off]);
    1629       r_entry->state=dead;
     1617      r_entry->set_state(dead);
    16301618       
    16311619      // notify about Routing State down
     
    16451633      if (r_entry) {
    16461634
    1647         if (r_entry->state == qn_established) {
     1635          if (r_entry->get_state() == qn_established) {
    16481636          EVLog(param.name, "Stopping RefreshQNode for downstream path as my upstream just timed out.");
    16491637
     
    16831671  if (r_entry)
    16841672  {
    1685     if (r_entry->timer_type != noconfirm) {
     1673      if (r_entry->get_timer_type_1() != noconfirm) {
    16861674      DLog(param.name, "Deliberately stopped timer, ignoring");
    16871675
     
    16911679    }
    16921680
    1693     if (r_entry->timer_id == timermsg->get_id()) {
     1681      if (r_entry->get_timer_id_1() == timermsg->get_id()) {
    16941682      DLog(param.name, "Timer slot 1, timer is valid, id: " << timermsg->get_id());
    16951683           
     
    17141702        // leave noConf timer stopped, kill state
    17151703        DLog(param.name, "Response retries stopped");
    1716         r_entry->state=dead;
     1704        r_entry->set_state(dead);
    17171705
    17181706        // notify about Routing State down
  • ntlp/trunk/src/routingtable.cpp

    r4223 r4231  
    6565     << "NLI:";
    6666
    67   if (nl)
    68     os << *nl;
     67  if (peer_nli)
     68    os << *peer_nli;
    6969  else
    7070    os << "n/a";
     
    165165  locktable(); //   >=>=>  LOCK  >=>=>
    166166
    167   entry->lock=false;
     167  entry->unlock();
    168168  if (key)
    169169  {
     
    408408    const routingentry* rtentry= cur->second;
    409409    if (rtentry)
    410       sii_handle= rtentry->sii_handle;
     410            sii_handle= rtentry->get_sii_handle();
    411411  }
    412412  unlocktable(); // <=<=< UNLOCK <=<=<
     
    487487    entry = (*cur).second;
    488488         
    489     if (entry->lock) {
     489    if (entry->is_locked()) {
    490490      ERRCLog(classname, "Tried to access LOCKED ENTRY!");
    491491      unlocktable(); // <=<=< UNLOCK <=<=<
    492492      return NULL;
    493493    }
    494     entry->lock=true;
     494    entry->set_lock();
    495495     
    496     DLog(classname, color[yellow] << "******* Returning entry for Session-ID "<< ((key->sid) ? key->sid->to_string() : "NULL") << " with state " << color[red] << statestring[entry->state] << color[off]);
     496    DLog(classname, color[yellow] << "******* Returning entry for Session-ID "<< ((key->sid) ? key->sid->to_string() : "NULL") << " with state " << color[red] << statestring[entry->get_state()] << color[off]);
    497497     
    498498  }
     
    529529    if (tmp)
    530530    {
    531       DLog(classname, color[yellow] << "******* Unlocking Session-ID "<< ((key->sid) ? key->sid->to_string() : "NULL") << " with state " << color[red] << statestring[tmp->state] << color[off]);
    532         tmp->lock=false;
     531            DLog(classname, color[yellow] << "******* Unlocking Session-ID "<< ((key->sid) ? key->sid->to_string() : "NULL") << " with state " << color[red] << statestring[tmp->get_state()] << color[off]);
     532            tmp->unlock();
    533533    }
    534534    else
     
    545545  locktable();   // >=>=>  LOCK  >=>=>
    546546
    547   entry->lock=false;
     547  entry->unlock();
    548548  // lookup
    549549  rt_iter rt_it= rtable.find(*key);
     
    582582  }
    583583 
    584   if (!rt_entry->lock) {
     584  if (!rt_entry->is_locked()) {
    585585    ERRCLog(classname,"You should ACQUIRE A LOCK PRIOR TO DELETING an entry!");
    586586    if (!table_already_locked)
     
    607607
    608608  // mark entry dead
    609   rt_entry->state=dead;
    610   rt_entry->lock=false;   
     609  rt_entry->set_state(dead);
     610  rt_entry->unlock();   
    611611  // switch to D-Mode, unsecure
    612   rt_entry->dmode=true;
    613   rt_entry->secure=false;
     612  rt_entry->set_dmode();
     613  rt_entry->set_secure(false);
    614614
    615615  const routingkey* key = &it->first;
     
    642642  }
    643643 
    644   if (!rt_entry->lock) {
     644  if (!rt_entry->is_locked()) {
    645645    ERRCLog(classname,"You should ACQUIRE A LOCK PRIOR TO DELETING an entry!");
    646646    unlocktable(); // <=<=< UNLOCK <=<=<
     
    966966          DLog(classname, color[red] << "Routing state must be set to 'BAD', which means killing state" << color[off]);
    967967         
    968           entry->rtstate=APIMsg::route_changed_status_bad;
     968          entry->set_errstate(APIMsg::route_changed_status_bad);
    969969         
    970970          if (urgency)
     
    972972            DLog(classname, color[red] << "Immediate re-installation is requested, starting new handshake" << color[off]);
    973973                           
    974             if (entry->state == qn_established)
     974            if (entry->get_state() == qn_established)
    975975            {
    976976                           
     
    992992              entry = lookup(key);
    993993              // unlock. this is not safe. shhhh...
    994               entry->lock=false;
     994              entry->unlock();
    995995                               
    996996              // drop to AWAITING_RESPONSE
    997               entry->state=qn_awaiting_response;
     997              entry->set_state(qn_awaiting_response);
    998998              //start NoResponse timer
    999999              TimerMsg* msg = new TimerMsg(message::qaddr_coordination,true);
    10001000              // starting timer, give pointer to routingkey
    1001               entry->timer_type_2=noresponse;
     1001              entry->set_timer_type_2(noresponse);
    10021002                                   
    10031003              uint32* timer_type = new uint32;
    1004               *timer_type = entry->timer_type_2;
     1004              *timer_type = entry->get_timer_type_2();
    10051005
    10061006              // set retry timeout back to initial value
     
    10091009              // start for 500msec (or whatever retryperiod is set to)
    10101010              msg->start_relative(0, entry->get_retry_timeout(),(void*) timer_type, (void*) key);
    1011               entry->timer_id_2=msg->get_id();
     1011              entry->set_timer_id_2(msg->get_id());
    10121012                                   
    10131013              DLog(classname, "NoResponse timer started");
     
    10181018            } // endif state==qn_established
    10191019                           
    1020             if (entry->state == rn_established)
     1020            if (entry->get_state() == rn_established)
    10211021            {
    10221022              DLog(classname, "I am RN, I cannot re-install state, even though it was requested simply going to 'DEAD'");
     
    10411041
    10421042        if (status==APIMsg::tentative)
    1043         {         Log(EVENT_LOG, LOG_NORMAL, classname, "Set Routingstate to 'tentative', GIST will notify on change");
    1044           entry->rtstate = APIMsg::route_changed_status_tentative;
     1043        {         
     1044          EVLog(classname, "Set Routingstate to 'tentative', GIST will notify on change");
     1045          entry->set_errstate(APIMsg::route_changed_status_tentative);
    10451046         
    10461047          // Drop only to qn_awaiting_refresh
     
    10501051                           
    10511052            // we can do so if we are Querier and there is nothing else going on
    1052             if (entry->state == qn_established)
     1053            if (entry->get_state() == qn_established)
    10531054            {
    10541055                           
     
    10561057                               
    10571058              // drop to AWAITING_RESPONSE
    1058               entry->state=qn_awaiting_refresh;
     1059              entry->set_state(qn_awaiting_refresh);
    10591060              //start NoResponse timer
    10601061              TimerMsg* msg = new TimerMsg(message::qaddr_coordination,true);
    10611062              // starting timer, give pointer to routingkey
    1062               entry->timer_type_2=noresponse;
     1063              entry->set_timer_type_2(noresponse);
    10631064                                   
    10641065              uint32* timer_type = new uint32;
    1065               *timer_type = entry->timer_type_2;
     1066              *timer_type = entry->get_timer_type_2();
    10661067                                   
    10671068              // set retry timeout back to initial value
     
    10701071              // start for 500msec (or whatever retryperiod is set to)
    10711072              msg->start_relative(0, entry->get_retry_timeout(),(void*) timer_type, (void*) key);
    1072               entry->timer_id_2=msg->get_id();
     1073              entry->set_timer_id_2(msg->get_id());
    10731074                                   
    10741075              DLog(classname, "NoResponse timer started");
     
    10791080            }
    10801081                           
    1081             if (entry->state == rn_established) {
     1082            if (entry->get_state() == rn_established) {
    10821083              DLog(classname, "I am RN, I cannot start a state refresh");
    10831084                               
     
    11311132      if (rte!=NULL)
    11321133      {
    1133         rte->rs_validity_time = lifetime;
     1134              rte->set_rs_validity_time(lifetime);
    11341135      }
    11351136      else
     
    11511152{
    11521153  // precondition: the message arrived via C-Mode
    1153   const ma_entry* ma= r_entry->nl ? lookup_ma(r_entry->nl) : 0;
     1154  const ma_entry* ma= r_entry->get_peer_nli() ? lookup_ma(r_entry->get_peer_nli()) : 0;
    11541155  if (ma)
    11551156  { // if an MA exists for the peer
     
    11601161      // if routing entry requires is, the MA should be secure, too,
    11611162      // otherwise unsecure data can be sent via secure MAs
    1162       return r_entry->secure ? ma->is_secure() : true;
     1163      return r_entry->is_secure() ? ma->is_secure() : true;
    11631164    }
    11641165    //    else
     
    11711172  // but we can check whether the source address matches
    11721173  // the requirements
    1173   if ( !r_entry->secure || (r_entry->secure && cap.is_secure(peer)) )
     1174  if ( !r_entry->is_secure() || (r_entry->is_secure() && cap.is_secure(peer)) )
    11741175  {
    11751176    // security was requested and message came via secure C-Mode transport
  • ntlp/trunk/src/routingtable.h

    r4225 r4231  
    258258/// an entry for the routing data vector
    259259class routingentry {
    260  public:
     260
     261public:
    261262  // constructor
    262263  routingentry(bool is_responder);
     
    265266  ~routingentry()
    266267  {
    267     if (nattrav) delete nattrav;
    268     if (translated_nli) delete translated_nli;
    269     if (nl) delete nl;
    270     if (qrc) delete qrc;
    271     if (tmppeer) delete tmppeer;
    272     if (tmppdu) delete tmppdu;
    273     if (mod_data) delete mod_data;
    274     if (sp) delete sp;
    275     if (sc) delete sc; 
    276     if (local_src) delete local_src;
     268    delete nattrav;
     269    delete translated_nli;
     270    delete peer_nli;
     271    delete qrc;
     272    delete tmppeer;
     273    delete tmppdu;
     274    delete mod_data;
     275    delete sp;
     276    delete sc; 
     277    delete local_src;
    277278  } // end destructor
    278279   
    279   routingentry(routingentry& n) : msg_id(0)
     280  routingentry(routingentry& n) :
     281          nattrav(n.nattrav ? n.nattrav->copy() : NULL),
     282          translated_nli(n.translated_nli ? n.translated_nli->copy() : NULL),
     283          is_responder(n.is_responder),
     284          dmode(n.dmode),
     285          secure(n.secure),
     286          peer_nli(n.peer_nli ? n.peer_nli->copy() : NULL),
     287          local_src(n.local_src ? n.local_src->copy() : NULL),
     288          state(n.state),
     289          lock(false), // NOTE: not a true copy
     290          qrc(NULL),   // NOTE: not a true copy
     291          timer_type(none), // NOTE: not a true copy
     292          timer_type_2(none), // NOTE: not a true copy
     293          timer_type_3(none), // NOTE: not a true copy
     294          timer_id(0), // NOTE: not a true copy
     295          timer_id_2(0), // NOTE: not a true copy
     296          timer_id_3(0), // NOTE: not a true copy
     297          rs_validity_time(n.rs_validity_time),
     298          ma_hold_time(n.ma_hold_time),
     299          in_if(n.in_if),
     300          out_if(n.out_if),
     301          tmppeer(NULL), // NOTE: not a true copy
     302          tmppdu(NULL),  // NOTE: not a true copy
     303          ghc(n.ghc),
     304          ip_ttl(n.ip_ttl),
     305          mod_data(n.mod_data ? n.mod_data->copy() :  NULL),
     306          rtstate(APIMsg::error_ok), // NOTE: not a true copy
     307          msg_id(0),  // NOTE: not a true copy
     308          sp(n.sp ? n.sp->copy() :  NULL),
     309          sc(n.sc ? n.sc->copy() :  NULL),
     310          sii_handle(n.sii_handle),
     311          retry_timeout(n.retry_timeout)
    280312  {
    281313    dataqueue.clear();
    282     if (n.nattrav) nattrav=n.nattrav->copy(); else nattrav = NULL;
    283     if (n.translated_nli) translated_nli=n.translated_nli->copy(); else translated_nli= NULL;
    284     dmode=n.dmode;
    285     secure=n.secure;
    286     if (n.nl) nl=n.nl->copy(); else nl = NULL;
    287     state=n.state;
    288     lock=false;
    289     qrc = NULL;
    290     if (n.tmppeer) tmppeer=n.tmppeer->copy(); else tmppeer = NULL;
    291     if (n.tmppdu) tmppdu=n.tmppdu->copy(); else tmppdu = NULL;
    292     if (n.mod_data) mod_data=n.mod_data->copy(); else mod_data = NULL;
    293     if (n.sp) sp = n.sp->copy(); else sp = NULL;
    294     if (n.sc) sc = n.sc->copy(); else sc = NULL;
    295     if (n.local_src) local_src = n.local_src->copy(); else local_src = NULL;
    296     ip_ttl=n.ip_ttl;
    297     ghc=n.ip_ttl;
    298     timer_type=none;
    299     timer_type_2=none;
    300     timer_type_3=none;
    301     timer_id = 0;
    302     timer_id_2 = 0;
    303     timer_id_3 = 0;
    304     rs_validity_time = n.rs_validity_time;
    305     ma_hold_time=n.ma_hold_time;
    306     in_if= n.in_if;
    307     out_if= n.out_if;
    308     rtstate = 0;
    309     sii_handle = n.sii_handle;
    310     retry_timeout = n.retry_timeout;
    311314  } // end copy constructor
    312315
    313   // get max retry timeout
    314   static uint32 get_retry_limit();
    315   // get default initial retry timeout
    316   static uint32 get_retry_period();
    317 
    318   /// get current retry_timeout
    319   uint32 get_retry_timeout() const { return retry_timeout; }
    320   /// reset timeout to local default
    321   uint32 reset_retry_timeout() { return retry_timeout= get_retry_period(); }
    322   /// perform exponential backoff
    323   void increase_retry_timeout() { if (!retry_limit_reached()) retry_timeout= 2 * retry_timeout; }
    324   /// returns true if max retry timeout is reached
    325   bool retry_limit_reached() const { return (retry_timeout > (get_retry_limit() - retry_timeout));  }
    326 
    327   /// returns whether node is responding node
    328   bool is_responding_node() const { return is_responder; };
    329   bool is_querying_node() const { return !is_responder; };
    330 
    331   /// get outgoing interface index
    332   uint16 get_outgoing_if() const { return out_if; }
    333 
    334   /// get incoming interface index
    335   uint16 get_incoming_if() const { return in_if; }
    336 
    337   /// set outgoing interface index
    338   void set_outgoing_if(uint16 out_if_index) { out_if= out_if_index; }
    339 
    340   /// set incoming interface index
    341   void set_incoming_if(uint16 incoming_if_index) { in_if= incoming_if_index; }
    342 
    343   const char* get_state_name() const { return (state<rt_state_max) ? statestring[state] : "state variable invalid - internal error"; };
    344 
    345   void set_local_src(const hostaddress& src) {
    346         local_src = src.copy();
    347         // must use plain IPv4 if possible
    348         local_src->convert_to_ipv4();
    349   }
    350 
    351   /// print routing entry as string
    352   string to_string() const;
     316
     317        /// print routing entry as string
     318        string to_string() const;
     319
     320        // get and set methods
     321        void set_nattraversal(const nattraversal* newnattrav) { delete (nattrav); nattrav= newnattrav ? newnattrav->copy() : NULL; }
     322        const nattraversal* get_nattraversal() const { return nattrav; }
     323
     324        void set_translated_nli(const nli* newnli) { delete (translated_nli); translated_nli= newnli ? newnli->copy() : NULL; }
     325        const nli* get_translated_nli() const { return translated_nli; }
     326
     327        void set_is_responding_node(bool is_responding_node= true) { is_responder= is_responding_node; }
     328        void set_is_querying_node(bool is_querying_node= true) { is_responder= !is_querying_node; }
     329
     330        /// returns whether node is responding node
     331        bool is_responding_node() const { return is_responder; };
     332        bool is_querying_node() const { return !is_responder; };
     333
     334        void set_dmode(bool d_mode= true) { dmode= d_mode; }
     335        void set_cmode(bool c_mode= true) { dmode= !c_mode; }
     336        bool is_dmode() const { return dmode; }
     337        bool is_cmode() const { return !dmode; }
     338
     339        void set_secure(bool securereq= true) { secure= securereq; }
     340        bool is_secure() const { return secure; }
     341
     342        void set_state(routingstate_t rs) { state= rs; }
     343        routingstate_t get_state() const { return state; }
     344
     345        void set_peer_nli(const nli* newnli) { delete (peer_nli); peer_nli= newnli ? newnli->copy() :  NULL; }
     346        const nli* get_peer_nli() const { return peer_nli; }
     347
     348        void set_querycookie(const querycookie* newqrc) { delete(qrc); qrc= newqrc ? newqrc->copy() : NULL; }
     349        querycookie* get_querycookie() const { return qrc; }
     350
     351        void set_rs_validity_time(uint32 routing_state_validity_time) { rs_validity_time= routing_state_validity_time; }
     352        uint32 get_rs_validity_time() const { return rs_validity_time; }
     353
     354        void set_ma_hold_time(uint32 ma_holdtime) { ma_hold_time= ma_holdtime; }
     355        uint32 get_ma_hold_time() const { return ma_hold_time; }
     356       
     357        void set_tmppeer(const appladdress* tmp_peer) { delete tmppeer; tmppeer= tmp_peer ? tmp_peer->copy() : NULL; }
     358        const appladdress* get_tmppeer() const { return tmppeer; }
     359        appladdress* deliver_tmppeer() { appladdress* dtmp_peer=tmppeer; tmppeer= NULL; return dtmp_peer; }
     360
     361        void set_tmppdu(const known_ntlp_pdu* tmp_pdu) { delete tmppdu; tmppdu= tmp_pdu ? tmp_pdu->copy() : NULL; }
     362        const known_ntlp_pdu* get_tmppdu() const { return tmppdu; }
     363        known_ntlp_pdu* deliver_tmppdu() { known_ntlp_pdu* dtmp_pdu=tmppdu; tmppdu= NULL; return dtmp_pdu; }
     364
     365        void set_gist_hop_count(uint32 newghc) { ghc= newghc; }
     366        uint32 get_gist_hop_count() const { return ghc; }
     367
     368        void set_ip_ttl(uint32 newip_ttl) { ip_ttl= newip_ttl; }
     369        uint32 get_ip_ttl() const { return ip_ttl; }
     370
     371        void set_sii_handle(uint32 newsii_handle) { sii_handle= newsii_handle; }
     372        uint32 get_sii_handle() const { return sii_handle; }
     373
     374
     375        void set_msg_id(msghandle_t new_msg_id) { msg_id= new_msg_id; }
     376        msghandle_t get_msg_id() const { return msg_id; }
     377
     378
     379        void set_errstate(APIMsg::error_t rs) { rtstate= rs; }
     380        APIMsg::error_t get_errstate() const { return rtstate; }
     381
     382        void set_sp(const stackprop* newsp) { delete sp; sp= newsp ? newsp->copy() :  NULL; }
     383        const stackprop* get_sp() const { return sp; }
     384
     385        void set_sc(const stack_conf_data* newsc) { delete sc; sc= newsc ? newsc->copy() :  NULL; }
     386        const stack_conf_data* get_sc() const { return sc; }
     387       
     388        // get max retry timeout
     389        static uint32 get_retry_limit();
     390        // get default initial retry timeout
     391        static uint32 get_retry_period();
     392       
     393        /// get current retry_timeout
     394        uint32 get_retry_timeout() const { return retry_timeout; }
     395        /// reset timeout to local default
     396        uint32 reset_retry_timeout() { return retry_timeout= get_retry_period(); }
     397        /// perform exponential backoff
     398        void increase_retry_timeout() { if (!retry_limit_reached()) retry_timeout= 2 * retry_timeout; }
     399        /// returns true if max retry timeout is reached
     400        bool retry_limit_reached() const { return (retry_timeout > (get_retry_limit() - retry_timeout));  }
     401       
     402       
     403        /// get outgoing interface index
     404        uint16 get_outgoing_if() const { return out_if; }
     405        /// set outgoing interface index
     406        void set_outgoing_if(uint16 out_if_index) { out_if= out_if_index; }
     407       
     408        /// get incoming interface index
     409        uint16 get_incoming_if() const { return in_if; }
     410        /// set incoming interface index
     411        void set_incoming_if(uint16 incoming_if_index) { in_if= incoming_if_index; }
     412       
     413        timer_type_t get_timer_type_1() const { return timer_type; }
     414        void set_timer_type_1(timer_type_t type) { timer_type= type; }
     415        timer_type_t get_timer_type_2() const { return timer_type_2; }
     416        void set_timer_type_2(timer_type_t type) { timer_type_2= type; }
     417        timer_type_t get_timer_type_3() const { return timer_type_3; }
     418        void set_timer_type_3(timer_type_t type) { timer_type_3= type; }
     419
     420        uint64 get_timer_id_1() const { return timer_id; }
     421        void set_timer_id_1(uint64 id) { timer_id= id; }
     422        uint64 get_timer_id_2() const { return timer_id_2; }
     423        void set_timer_id_2(uint64 id) { timer_id_2= id; }
     424        uint64 get_timer_id_3() const { return timer_id_3; }
     425        void set_timer_id_3(uint64 id) { timer_id_3= id; }
     426
     427        const char* get_state_name() const { return (state<rt_state_max) ? statestring[state] : "state variable invalid - internal error"; };
     428       
     429        void set_local_src(const hostaddress& src) {
     430                delete local_src;
     431                local_src = src.copy();
     432                // must use plain IPv4 if possible
     433                local_src->convert_to_ipv4();
     434        }
     435
     436        const hostaddress* get_local_src() const  { return local_src; }
     437
     438        void set_mod_data(const nslpdata* data) { delete mod_data; mod_data= data ? data->copy() : NULL; }
     439        const nslpdata* get_mod_data() const { return mod_data; }
     440        nslpdata* deliver_mod_data() {  nslpdata* tmp_data= mod_data; mod_data= NULL; return tmp_data; }
     441
     442        void set_lock() { lock= true; }
     443        void unlock() { lock= false; }
     444        bool is_locked() const { return lock; }
    353445
    354446  /// enqueued DATA PAYLOAD
    355447  vector<queueentry*> dataqueue;
     448
     449private:
    356450   
    357451  /// saved NAT Traversal object
     
    369463  /// NLI object is used to reference messaging association in MA_table
    370464  /// and provides DMode Adressing (Port is Well-Known)
    371   nli* nl;
     465  nli* peer_nli;
    372466
    373467  // The local address that was used as source to create this entry
     
    418512   
    419513  /// save APIMsg::error_t Routingstate which is sent to NSLP
    420   uint16 rtstate;
     514  APIMsg::error_t rtstate;
    421515   
    422516  /// for saving of Message ID of Message which initiated handshake
     
    430524  uint32 sii_handle;
    431525
    432  private:
    433526  /// Retry timeout for Message Retransmits in ms
    434527  uint32 retry_timeout;
     
    691784    dmode(true),
    692785    secure(false),
    693     nl(NULL),
     786    peer_nli(NULL),
     787    local_src(NULL),
    694788    state(initial),
    695789    lock(false),
     
    710804    ip_ttl(0),
    711805    mod_data(NULL),
    712     rtstate(0),
     806    rtstate(APIMsg::error_ok),
    713807    msg_id(0),
    714808    sp(NULL),
Note: See TracChangeset for help on using the changeset viewer.