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

Changeset 4212


Ignore:
Timestamp:
Aug 6, 2009, 2:28:55 PM (8 years ago)
Author:
stud-lenk
Message:

Re-sync with trunk (up to SVN rev. r4211)

Location:
ntlp/branches/20090723-multicast
Files:
2 deleted
44 edited
4 copied

Legend:

Unmodified
Added
Removed
  • ntlp/branches/20090723-multicast

  • ntlp/branches/20090723-multicast/Makefile

    r3130 r4212  
    6868
    6969gist:
    70         $(MAKE) -C $(GIST_SRC) 
     70        $(MAKE) -C $(GIST_SRC)
    7171
    7272setperms:
  • ntlp/branches/20090723-multicast/include/apimessage.h

    r4108 r4212  
    190190            route_changed_status_good,
    191191            route_changed_status_bad,
    192             route_changed_status_tentative
     192            route_changed_status_tentative,
     193            route_changed_status_home_binding,
     194            route_changed_status_binding
    193195        }; // end error_t
    194196
     
    322324        bool get_sii_presence() const {return sii_present;}
    323325
     326        hostaddress *get_local_addr() const {return local_addr;}
     327        void set_local_addr(hostaddress *ls) {local_addr = ls;}
     328
    324329        /// inbound interface index
    325330        void set_inbound_ifidx(uint16 if_index) { inbound_if_index= if_index; }
     
    391396        /// NSLPIDpresent Flag
    392397        bool sii_present;
     398
     399        /// The local source this message should be sent from
     400        hostaddress *local_addr;
    393401
    394402        /// interface index on which the message was received
     
    416424            if (cur != nslptable.end()){
    417425               
    418                 //DLog("NSLPtable", "Successfully looked up API caller address for NSLPID " << nslpid);
     426                DLog("NSLPtable", "Successfully looked up API caller address for NSLPID " << nslpid);
    419427                return ((*cur).second);   
    420428           
     
    427435        }
    428436
    429         inline void save_address(uint32 nslpid, message::qaddr_t address) { nslptable[nslpid] = address; }
     437        inline void save_address(uint32 nslpid, message::qaddr_t address)
     438        {
     439            DLog("NSLPtable", "Saving address for NSLP ID " << nslpid << " at " << address);
     440            nslptable[nslpid] = address;
     441        }
    430442        inline
    431443        NSLPtable() {}
     
    433445        ~NSLPtable() {}
    434446       
    435     private:
     447/* XXX:   private: */
    436448        nslptable_t nslptable;
    437449       
  • ntlp/branches/20090723-multicast/include/apiwrapper.h

    r3674 r4212  
    4141#include "goettingen_api.h"
    4242
     43#include "addresslist.h"
    4344
    4445// Constants of Goettingen's GIST API
     
    7778    APIWrapperParam(TP* proto,
    7879                    const message::qaddr_t clientqueue,
    79                     const in_addr localv4,
    80                     const in6_addr localv6,
     80                    AddressList &addresses,
    8181                    bool instantestablish,
    8282                    uint32 sleep_time = ThreadParam::default_sleep_time);
     
    8484    const message::qaddr_t clientqueue;
    8585    bool instantestablish;
    86     in_addr localv4;
    87     in6_addr localv6;
     86    AddressList &addresses;
    8887
    8988}; // end SignalingParam
  • ntlp/branches/20090723-multicast/include/gist_conf.h

    r4200 r4212  
    5050    gistconf_localaddrv4,
    5151    gistconf_localaddrv6,
     52    gistconf_home_netprefix,
     53    gistconf_home_address,
     54    gistconf_coa_interfaces,
     55    gistconf_homeagent_address,
     56    gistconf_homeagent_address_alt,
    5257    gistconf_retrylimit,
    5358    gistconf_retryperiod,
  • ntlp/branches/20090723-multicast/include/mri.h

    r3674 r4212  
    6969        /// returns the destination address of the signaling packet depending on the MRI
    7070        virtual appladdress* determine_dest_address() const = 0;
    71 
    72         /// returns the appropriate local outgoing interface for the flow
    73         virtual uint16 get_local_if() const = 0;
    7471   
    7572        /// returns the IP Version
  • ntlp/branches/20090723-multicast/include/mri_est.h

    r3674 r4212  
    113113
    114114        virtual appladdress* determine_dest_address() const { return new appladdress(dest_signaling_addr,prot_udp,GIST_default_port); }
    115 
    116         // Returns the appropriate local outgoing interface for the flow
    117         virtual uint16 get_local_if() const { return mri_pc.get_local_if(); }
    118115   
    119116        // Returns the IP Version
  • ntlp/branches/20090723-multicast/include/mri_le.h

    r3674 r4212  
    7878
    7979        virtual appladdress* determine_dest_address() const;
    80         virtual uint16 get_local_if() const;
    8180        virtual void invertDirection();
    8281
  • ntlp/branches/20090723-multicast/include/mri_pc.h

    r3674 r4212  
    9494
    9595        virtual appladdress* determine_dest_address() const;
    96         virtual uint16 get_local_if() const;
    9796
    9897
     
    138137                Destination_Port = 1 << 6,
    139138                Direction        = 1 << 5
     139        };
     140
     141        struct ltmri {
     142                inline bool operator()(const mri_pathcoupled *a,
     143                    const mri_pathcoupled *b) const {
     144                        hostaddress::ltaddr ltaddr;
     145                        if (ltaddr(&a->sourceaddress, &b->sourceaddress))
     146                                return true;
     147                        return ltaddr(&a->destaddress, &b->destaddress);
     148                }
    140149        };
    141150
  • ntlp/branches/20090723-multicast/include/ntlp_starter.h

    r4108 r4212  
    3535#include "threads.h"
    3636#include "address.h"
     37#include "addresslist.h"
     38#include "flowinfo.h"
    3739
    3840#include "ntlp_global_constants.h"
     
    4648/// starter module parameters
    4749struct NTLPStarterParam : public ThreadParam {
    48   NTLPStarterParam()   : ThreadParam(ThreadParam::default_sleep_time, "GIST Starter") {}
     50        AddressList *addresses;
     51        Flowinfo *fi_service;
     52
     53                NTLPStarterParam()   : ThreadParam(ThreadParam::default_sleep_time, "GIST Starter"), addresses(0), fi_service(0) {}
    4954}; // end NTLPStarterParam
    5055
  • ntlp/branches/20090723-multicast/src/GISTConsole.cpp

    r4108 r4212  
    137137
    138138GISTConsole::GISTConsole(const GISTConsoleParam& p)
    139     : Thread(p), param(p)
     139        : Thread(p), param(p), prompt("gist>")
    140140{
    141141        commands["usage"] = &GISTConsole::usage;
     
    274274                        out_buf += (char *)buf;
    275275                out_buf += "'\n";
    276                 out_buf += "# type ?<Return> for help.\n>";
     276                out_buf += "# type ?<Return> for help.\n";
     277                out_buf += prompt;
    277278
    278279                send();
     
    352353                        }
    353354                }
    354                 out_buf=">";
     355                out_buf=prompt;
    355356                send();
    356357
  • ntlp/branches/20090723-multicast/src/GISTConsole.h

    r4108 r4212  
    5454        int sockfd, clientfd;
    5555
     56        string prompt;
     57
    5658        string out_buf, in_buf;
    5759        char buf[1024];
  • ntlp/branches/20090723-multicast/src/Makefile

    r4108 r4212  
    2121#     make DEBUGGING= LOGGING=1 OPTIMIZATION=-O2
    2222#
     23
     24DISTDIR?=$(CURDIR)/../..
     25include $(DISTDIR)/Makefile.inc
     26
    2327DEBUGGING       = 1                     # the undefined value disables debugging
    2428LOGGING         = 1                     # the undefined value disables logging
     
    5054#CFLAGS         = --pedantic -O2 -g -Wno-long-long -Wall $(GIST_CXXFLAGS) # development (valgrind)
    5155CFLAGS          = --pedantic -Wno-long-long -Wall $(GIST_CXXFLAGS) -D GIST_VSTR=\"$(GIST_RELEASE)\"
     56CFLAGS         += -Wno-deprecated -Werror
    5257
    5358CLINK           = -c -o
     
    6570NTLP_PDUOBJS := $(patsubst %.cpp,%.o,$(NTLP_PDUSRC))
    6671
    67 NTLP_MAIN_OBJ = ntlp_main.o
    68 NTLP_SRCS =  $(wildcard *.cpp) $(NTLP_PDUSRC)
     72TMP_NTLP_SRCS =  $(wildcard *.cpp) $(NTLP_PDUSRC)
     73ifndef USE_FLOWINFO
     74NTLP_SRCS = $(filter-out flowinfo.cpp, $(TMP_NTLP_SRCS))
     75else
     76NTLP_SRCS = $(TMP_NTLP_SRCS)
     77CFLAGS += $(FLOWINFO_CFLAGS)
     78endif
    6979NTLP_ALLOBJS=  $(patsubst %.cpp,%.o,$(NTLP_SRCS))
    7080NTLP_OBJS=  $(filter-out $(NTLP_MAIN_OBJ),$(NTLP_ALLOBJS))
     
    7585GISTLIB=libGIST.a
    7686GISTLIB_SHARED=libGIST.so
    77 
    78 DISTDIR?=$(CURDIR)/../..
    79 include $(DISTDIR)/Makefile.inc
    8087
    8188ifdef SCTP_DIR
     
    160167        $(CPP) -shared -o $@ $?
    161168
     169test_flowinfo: test_flowinfo.o $(GISTLIB) $(LIBS)
     170        $(CPP) $(CFLAGS) -o $@ $^  -L . -lGIST $(LIBDIRS) $(SHLIBS) $(STATIC_LIBS)
     171
    162172simpleclient: simpleclient.o
    163173        $(CPP) $(CFLAGS) -o $@ $^ $(LIBDIRS) $(SHLIBS) $(STATIC_LIBS)
     
    217227# always checks for new things in protlib subdirs
    218228protliblib:
    219                 $(MAKE) -C $(PROTLIB_SRC)  $(PROTLIB_MAKEFLAGS)
     229                $(MAKE) -C $(PROTLIB_SRC) $(PROTLIB_MAKEFLAGS)
    220230
    221231$(PROTLIB_LIB):
    222                 $(MAKE) -C $(PROTLIB_SRC)  $(PROTLIB_MAKEFLAGS) $(@F)
     232                $(MAKE) -C $(PROTLIB_SRC) $(PROTLIB_MAKEFLAGS) $(@F)
    223233
    224234$(FQUEUE_LIB):
    225                 $(MAKE) -C $(FQUEUE_DIR) 
     235                $(MAKE) -C $(FQUEUE_DIR)
    226236
    227237$(SCTP_LIB):
    228         $(MAKE) -C $(SCTP_DIR) 
     238        $(MAKE) -C $(SCTP_DIR)
    229239
    230240clean: 
  • ntlp/branches/20090723-multicast/src/apimessage.cpp

    r3674 r4212  
    104104        payload_status(good),
    105105        payload_urgent(false),
     106        local_addr(0),
    106107        inbound_if_index(0),
    107108        inbound_if_internal(false)
    108     {
     109{
    109110        payload_tx_attr.reliable=false;
    110111        payload_tx_attr.secure=false;
     
    118119        if (payload_sid) delete payload_sid;
    119120        if (payload_mr) delete payload_mr;
     121        if (local_addr) delete local_addr;
    120122
    121123    } // end destructor
     
    152154            "route_changed_status_good",
    153155            "route_changed_status_bad",
    154             "route_changed_status_tentative"
     156            "route_changed_status_tentative",
     157            "route_changed_status_home_binding",
     158            "route_changed_status_binding"
    155159    };
    156160
     
    330334        delete payload_mr;
    331335        delete payload_sid;
    332        
     336        delete local_addr;
    333337
    334338    }
  • ntlp/branches/20090723-multicast/src/apiwrapper.cpp

    r3674 r4212  
    5050    APIWrapperParam::APIWrapperParam(TP* proto,
    5151                                     const message::qaddr_t clientqueue,
    52                                      in_addr localv4,
    53                                      in6_addr localv6,
     52                                     AddressList &addresses,
    5453                                     bool instantestablish,
    5554                                     uint32 sleep_time)
     
    5857          clientqueue(clientqueue),
    5958          instantestablish(instantestablish),
    60           localv4(localv4),
    61           localv6(localv6)
     59          addresses(addresses)
    6260       
    6361    {
     
    13051303        uint32 tmp = 4;
    13061304        answer->encode((uchar*) &tmp, 4);
    1307         answer->encode((uchar*) &(param.localv4), 4);
     1305
     1306        netaddress *na = param.addresses.get_first(AddressList::ConfiguredAddr_P, true);
     1307        struct in_addr ia;
     1308        na->get_ip(ia);
     1309
     1310        answer->encode((uchar*) &(ia), 4);
     1311        delete na;
    13081312
    13091313    } else {
     
    13161320        uint32 tmp = 4;
    13171321        answer->encode((uchar*) &tmp, 4);
    1318         answer->encode((uchar*) &(param.localv6), 16);
    1319 
     1322        netaddress *na = param.addresses.get_first(AddressList::ConfiguredAddr_P, false);
     1323        struct in6_addr ia;
     1324        na->get_ip(ia);
     1325
     1326        answer->encode((uchar*) &(ia), 4);
     1327        delete na;
    13201328
    13211329    }
  • ntlp/branches/20090723-multicast/src/gist_conf.cpp

    r4200 r4212  
    5757  registerPar( new configpar< hostaddresslist_t >(gist_realm, gistconf_localaddrv4, "localaddr-v4", "Local IPv4 listen addresses", true, list<hostaddress>() ) );
    5858  registerPar( new configpar< hostaddresslist_t >(gist_realm, gistconf_localaddrv6, "localaddr-v6", "Local IPv6 listen addresses", true, list<hostaddress>() ) );
     59  registerPar( new configpar< netaddress >(gist_realm, gistconf_home_netprefix, "home-netprefix", "Home Network Prefix (Mobility)", true) );
     60  registerPar( new configpar< hostaddress >(gist_realm, gistconf_home_address, "home-address", "Home Address (Mobility)", true) );
     61  registerPar( new configpar< string >(gist_realm, gistconf_coa_interfaces, "coa-interfaces", "Care-Of Interfaces (Mobility)", true) );
     62  registerPar( new configpar< hostaddress >(gist_realm, gistconf_homeagent_address, "homeagent-address", "Home Agent Address (Mobility)", true) );
     63  registerPar( new configpar< hostaddress >(gist_realm, gistconf_homeagent_address_alt, "homeagent-address-alt", "Home Agent Alternative Address (Mobility)", true) );
    5964  registerPar( new configpar<uint32>(gist_realm, gistconf_retrylimit,  "retry-limit", "Upper limit for retry limit threshold (ms)", true, retrylimit_default, "ms") );
    6065  registerPar( new configpar<uint32>(gist_realm, gistconf_retryperiod, "retry-period", "Retries will be started initially after this period (ms)", true, retryperiod_default, "ms") );
  • ntlp/branches/20090723-multicast/src/ntlp_main.cpp

    r4108 r4212  
    6868#include "threadsafe_db.h"
    6969#include "apimessage.h"
     70#include "flowinfo.h"
    7071
    7172#include "ntlp_global_constants.h"
     
    494495  }
    495496
     497    // this will set default values
     498    NTLPStarterParam ntlppar;
     499    AddressList *addresses = new AddressList();
     500
     501    if (ntlpv4addr.size() == 0 && ntlpv6addr.size() == 0) {
     502        addresses->add_host_prop(NULL, AddressList::ConfiguredAddr_P);
     503    }
     504
     505    if (!ntlpv4addr.empty())
     506    {
     507            hostaddresslist_t::iterator it= ntlpv4addr.begin();
     508            while (it != ntlpv4addr.end())
     509            {
     510                    netaddress na(*it);
     511                    na.set_pref_len(32);
     512                    addresses->add_property(na, AddressList::ConfiguredAddr_P);
     513                    it++;
     514            } // end while
     515    }
     516
     517    if (!ntlpv6addr.empty())
     518    {
     519            hostaddresslist_t::iterator it= ntlpv6addr.begin();
     520           
     521            while (it != ntlpv6addr.end())
     522            {
     523                    netaddress na(*it);
     524                    na.set_pref_len(128);
     525                    addresses->add_property(na, AddressList::ConfiguredAddr_P);
     526                    it++;
     527            } // end while
     528    }
     529   
     530    // set specified IP addresses
     531    ntlppar.addresses = addresses;
     532   
    496533    // fill the parameters from configfile or command line
    497534    // (parameters given by command line will override these)
     
    518555    if (config[gconf.parname(gistconf_debug_tp)].empty() == false) gconf.setpar(gistconf_debug_tp, StringToBool(config[ gconf.parname(gistconf_debug_tp)]));
    519556
     557#ifdef USE_FLOWINFO
     558    // Create a flowinfoservice thread
     559    FlowinfoParam fiparam;
     560    ThreadStarter<Flowinfo, FlowinfoParam> fithread(1, fiparam);
     561    fithread.start_processing();
     562
     563    // record the flowinfoservice thread in the ntlp_param
     564    ntlppar.fi_service = fithread.get_thread_object();
     565#endif
     566
    520567    // give the parameters to NTLP Starter
    521     NTLPStarterParam ntlppar;
    522568    ThreadStarter<NTLPStarter,NTLPStarterParam> ntlpthread(1,ntlppar);
    523569    global_ntlpthread_p= ntlpthread.get_thread_object();
  • ntlp/branches/20090723-multicast/src/ntlp_proto.cpp

    r4108 r4212  
    9898/***** class GIST *****/
    9999
    100 NTLP::NTLP(const appladdress& def_orig_addr, nli& localnliv4, nli& localnliv6, uint16 wkp, IE::coding_t c, bool acct_unauth)
    101         : localnliv4(localnliv4), localnliv6(localnliv6), coding(c), accept_unauthenticated(acct_unauth), default_originator_addr(def_orig_addr), wkp(wkp) {
     100NTLP::NTLP(AddressList &addresses, uint16 wkp, IE::coding_t c, bool acct_unauth)
     101        : addresses(addresses), coding(c), accept_unauthenticated(acct_unauth), wkp(wkp) {
    102102} // end constructor
    103103
     
    114114  if (ha)
    115115  {
    116     if (NTLP::default_orig_haddr() && ha->hostaddress::operator==(*NTLP::default_orig_haddr()))
    117     {
    118       return true;
    119     }
    120     else
    121       return false;
     116    netaddress na(*ha);
     117    return addresses.addr_is(na, AddressList::ConfiguredAddr_P);
    122118  }
    123119  else
     
    245241    {
    246242      // check for NLI transport match
    247       if ( (peeraddr.is_ipv4() && pdu->get_mri()->get_ip_version()!=4)
    248           ||
    249           (peeraddr.is_ipv6() && !peeraddr.is_mapped_ip() && pdu->get_mri()->get_ip_version()!=6))
    250 
     243      if (
     244           (peeraddr.is_ipv4() && pdu->get_mri()->get_ip_version()!=4)
     245           ||
     246           (peeraddr.is_ipv6() && !peeraddr.is_mapped_ip() && pdu->get_mri()->get_ip_version()!=6)
     247         )
    251248      {
    252249        ERRLog(NTLP::modname, "MRI IP version ("<< (int) pdu->get_mri()->get_ip_version() 
     
    976973  if (ip_version == 4)
    977974  {
    978     resultpdu = new error(localnliv4.copy(), errobj);
     975    // XXXMOB: resultpdu = new error(localnliv4.copy(), errobj);
    979976  }
    980977  else
    981978  {
    982     resultpdu = new error(localnliv6.copy(), errobj);
     979    // XXXMOB: resultpdu = new error(localnliv6.copy(), errobj);
    983980  }
    984981 
  • ntlp/branches/20090723-multicast/src/ntlp_proto.h

    r4108 r4212  
    4242#include "threadsafe_db.h"
    4343#include "logfile.h"
     44
     45#include "addresslist.h"
    4446
    4547#ifndef NSIS_OMNETPP_SIM
     
    104106
    105107  /// constructor
    106   NTLP(const appladdress& defaultoriginator, nli& localnliv4, nli& localnliv6, uint16 wkp, IE::coding_t c = IE::protocol_v1, bool acct_unauth = true);
     108  NTLP(AddressList &addresses, uint16 wkp, IE::coding_t c = IE::protocol_v1, bool acct_unauth = true);
    107109  ~NTLP();
    108110  error_t process_tp_recv_msg(NetMsg& msg, appladdress& addr,
     
    116118  bool revoke(gp_id_t reqid);
    117119
    118   /// returns the default originator address that is used for local msg references for example
    119   const hostaddress* default_orig_haddr() const { return static_cast<const hostaddress*>(&default_originator_addr); }
    120   const appladdress* default_orig_addr() const { return &default_originator_addr; }
    121120  /// checks whether address belongs to pool of own addresses
    122121  bool isown_address(const hostaddress* ha) const;
     
    127126    bool set_orig_msgref(known_ntlp_pdu& pdu);
    128127   
    129     nli& localnliv4;
    130     nli& localnliv6;
     128    AddressList &addresses;
    131129
    132130    error_t generate_errorpdu(NetMsg& msg,
     
    144142    /// accept unauthenticated messages
    145143    const bool accept_unauthenticated;
    146     /// default originator address, used in message references
    147     appladdress default_originator_addr;
    148144    ///the well-known-GIST-port
    149145    uint16 wkp;
  • ntlp/branches/20090723-multicast/src/ntlp_starter.cpp

    r4200 r4212  
    118118#endif
    119119  cout << color[blue] << gist_name << " v" << gist_releasestring
    120        << " ($Rev$ - development build) (C) 2005-2008 Universitaet Karlsruhe (TH)" << color[off] << endl;
     120       << " ($Rev$ - development build) (C) 2005-2009 Universitaet Karlsruhe (TH)" << color[off] << endl;
    121121  cout << endl;
    122122  cout << "Parameters:" << endl;
     
    289289 
    290290  @ Routing Table Object
    291   @ initial retry period (in msec) for exponential backoff retransmissions
    292   @ retry limit period for retransmissions
    293   @ retry factor: Multiplicate with rs_validity_time to get Refresh_QNode timer value (e.g. "0.8", "0.9")
    294   @ rs_validity_time: Default local state validity time in seconds
    295   @ refreshtime: Maximum local refrsh period (refresh based on peer rs_validity_time, if it is less than this parameter)
    296   @ MA-Hold-Time: The time Messaging Associations will be kept open -> Don't exceed the specific TP mod. timeout!!
    297291  @ Secretmanager Object
    298292  @ nslptable hashmap
     
    310304                        gconf.getpar<uint16>(gistconf_secrets_length));
    311305   
    312   // BUILD a local NLI!
    313  
    314   // NLI: Who are WE?
    315        
    316306  // PI
    317307  peer_identity* mypi=new peer_identity();
    318308 
    319   EVLog(param.name, "Peer Identity initialized: " <<  color[magenta] << mypi << color[off]);
    320  
    321   in6_addr* addr6=NULL;
    322   in_addr* addr4=NULL;
    323  
    324   netaddress* loc_if4 = NULL;
    325   netaddress* loc_if6 = NULL;
    326        
    327   // initialise TTL with default value
    328   uint32 ttl = 0;
    329 
     309  EVLog(param.name, "Peer Identity initialized: " <<  color[magenta] << *mypi << color[off]);
     310 
    330311  // ================================================================================================
    331312  // configure local IP adresses
    332313  // ================================================================================================
    333314
    334   // take the first local IPv4 and IPv6 addresses of the host to put in NLI objects describing our node
    335   char* buffer = new char[255];
    336   gethostname(buffer, 255);
    337 
    338   hostaddresslist_t& localaddrv4= gconf.getparref< hostaddresslist_t >(gistconf_localaddrv4);
    339   if ( localaddrv4.size() == 0 ) {
    340    
    341     DLog(param.name,
    342          "Looking up the main IPv4 Address for host " << buffer);
    343    
    344     hostent* host = gethostbyname2(buffer, AF_INET);
    345    
    346     uint8 retries = 0;
    347    
    348     while (!host && (retries < 20)) {
    349       // lookup IPv4
    350       // TODO use getaddrinfo()
    351       host=gethostbyname2(buffer, AF_INET);
    352       if (!host) cout << "retrying reverse DNS lookup" << endl;
    353       retries++;
    354     }
    355    
    356     if (!host) {
    357       DLog(param.name, "Communication via IPv4 not possible, "
    358            "host has no A record");
    359       addr4= new in_addr;
    360     } else {
    361       addr4= (struct in_addr *) *host->h_addr_list;
    362     }
    363     loc_if4= new netaddress();
    364     loc_if4->set_ip(*addr4);
    365    
    366     if (!host)
    367       delete addr4;
    368 
    369   } else {
    370     DLog(param.name, "This instance was given a specified IP address: "
    371          << localaddrv4.front());
    372     loc_if4= new netaddress(localaddrv4.front());
    373   }
    374  
    375   hostaddresslist_t& localaddrv6= gconf.getparref< hostaddresslist_t >(gistconf_localaddrv6);
    376   if ( localaddrv6.size() == 0 ) {
    377    
    378     DLog(param.name, "Looking up the main IPv6 Address for host " << buffer);
    379    
    380     hostent* host = gethostbyname2(buffer, AF_INET6);
    381    
    382     uint8 retries = 0;
    383    
    384     while (!host && (retries < dnslookup_retries_max)) {
    385       // lookup IPv6
    386       host=gethostbyname2(buffer, AF_INET6);
    387       if (!host) cout << "retrying reverse DNS lookup" << endl;
    388       retries++;
    389     }
    390    
    391     if (!host) {
    392       WLog(param.name, "Communication via IPv6 not possible, "
    393            "host has no AAAA record");
    394       addr6= new(nothrow) in6_addr(in6addr_any);
    395     } else {
    396       addr6= reinterpret_cast<struct in6_addr *>(*host->h_addr_list);
    397     }
    398    
    399     loc_if6=new netaddress();
    400     if (addr6)
    401       loc_if6->set_ip(*addr6);
    402 
    403     if (!host)
    404       delete addr6;
    405 
    406   } else {
    407     DLog(param.name, "This instance was given a specified IP address: "
    408          << localaddrv6.front());
    409     loc_if6= new netaddress(localaddrv6.front());
    410   }   
     315  AddressList *addresses= NULL;
     316  if (param.addresses == 0) {
     317          addresses = new AddressList();
     318          addresses->add_host_prop(NULL, AddressList::ConfiguredAddr_P);
     319  }
     320  else {
     321          addresses = param.addresses;
     322  }
     323
     324  AddressList::addrlist_t *alist = addresses->get_addrs(
     325                                     AddressList::ConfiguredAddr_P);
     326  if (alist != 0) {
     327    DLog(param.name, "Address list: ");
     328    AddressList::addrlist_t::iterator it;
     329    for (it = alist->begin(); it != alist->end(); it++)
     330      DLog(param.name, "            " << *it);
     331  }
     332  delete alist;
     333
     334
     335#ifdef USE_FLOWINFO
     336  if (param.fi_service == NULL) {
     337    DLog(param.name, "No Flowinfoservice provided in ntlp parameter!");
     338    abort();
     339  }
     340#endif 
    411341 
    412342  DLog(param.name,
    413343       "NLI initialisation, IP TTL is set to 0 (unspecified)");
    414  
    415   DLog(param.name, "Derived Address for IPv4: " << *loc_if4);
    416   DLog(param.name, "Derived Address for IPv6: " << *loc_if6);
    417 
    418   nli localnliv4(ttl, gconf.getpar<uint32>(gistconf_rs_validity_time), mypi, *loc_if4);
    419   nli localnliv6(ttl, gconf.getpar<uint32>(gistconf_rs_validity_time), mypi, *loc_if6);
    420  
     344
     345  uint32_t ttl = 0;
     346
     347  netaddress na;
     348  nli nli_tmpl(ttl, gconf.getpar<uint32>(gistconf_rs_validity_time), mypi, na);
    421349 
    422350  DLog(param.name, "Startup phase 4: Starting Processing Module");
     
    428356 
    429357  StatemoduleParam smpar(rt,
    430                          localnliv4,
    431                          localnliv6,
     358                         nli_tmpl,
     359                         *addresses,
     360                         param.fi_service,
    432361                         secrets,
    433362                         nslptable,
     
    444373  DLog(param.name,
    445374       "Startup phase 5: Starting UNIX Domain socket interface");
    446 
    447   in_addr localv4;
    448   in6_addr localv6;
    449   loc_if4->get_ip(localv4);
    450   loc_if6->get_ip(localv6);
    451375
    452376  // start as SERVER and connect it to qaddr_api_0 (which is the APIWrapper!)
     
    472396  APIWrapperParam apipar = APIWrapperParam(udsproto,
    473397                                           message::qaddr_coordination,
    474                                            localv4,
    475                                            localv6,
     398                                           *addresses,
    476399                                           true);
    477400  ThreadStarter<APIWrapper,APIWrapperParam> apithread(1,apipar);
     
    480403
    481404       
    482   SignalingNTLPParam sigpar(pm, localnliv4, localnliv6, nslptable, gconf.getpar<uint16>(gistconf_udpport));
     405  SignalingNTLPParam sigpar(pm,  nli_tmpl, *addresses, nslptable, gconf.getpar<uint16>(gistconf_udpport), param.fi_service);
    483406  ThreadStarter<SignalingNTLP,SignalingNTLPParam> signaling(1,sigpar); 
    484407       
     
    651574  DLog(param.name, "Shutdown phase 5: Cleaning Up");
    652575
    653   delete loc_if4;
    654   delete loc_if6;
     576  delete mypi;
     577
    655578}
    656579
  • ntlp/branches/20090723-multicast/src/ntlp_statemodule.h

    r4108 r4212  
    4545#include "capability.h"
    4646#include "authorized_peer_db.h"
     47#include "flowinfo.h"
    4748
    4849// forward declaration from timer_module.h
     
    7576struct StatemoduleParam : public ThreadParam {
    7677  StatemoduleParam(routingtable& rt,
    77                    nli& localnliv4,
    78                    nli& localnliv6,
     78                   nli &nli_tmpl,
     79                   AddressList &addresses,
     80                   Flowinfo *fi_service,
    7981                   secretmanager& secrets,
    8082                   NSLPtable& nslptable,
     
    8587  const message::qaddr_t qaddr_int;
    8688  routingtable& rt;
    87   nli& localnliv4;
    88   nli& localnliv6;
    89 
     89  nli &nli_tmpl;
     90  AddressList &addresses;
     91  Flowinfo *fi_service;
     92  uint32 retrylimit;
     93  uint32 retryperiod;
     94  float retryfactor;
     95  uint32 rs_validity_time;
     96  uint32 refreshtime;
     97  uint32 ma_hold_time;
    9098  secretmanager& secrets;
    9199
     
    225233  /// process timers
    226234  void process_timer_msg(TimerMsg* timermsg);
     235
     236  /// process mobility events
     237  void process_mobility_msg(MobilityMsg* mobmsg);
    227238       
    228239  /// check if a stackprofile is applicable
     
    233244             
    234245  /// construct a local NLI information object describing the node
    235   nli* build_local_nli(uint8 ip_version, routingentry* re= NULL);
     246  nli* build_local_nli(uint8 ip_version, const netaddress &dest, routingentry* re= NULL);
    236247
    237248  /// enqueue data in a message queue and start Queue Poll timer
  • ntlp/branches/20090723-multicast/src/ntlp_statemodule_api.cpp

    r4108 r4212  
    3939
    4040#include "gist_conf.h"
     41#include "rfc5014_hack.h"
    4142
    4243namespace ntlp {
     
    425426  hostaddress src = apimsg->get_mri()->get_sourceaddress();
    426427  hostaddress dst = apimsg->get_mri()->get_destaddress();
    427  
     428
    428429  if (src.is_ipv6() != dst.is_ipv6())
    429430  {
     
    465466    send_data_explicit(apimsg);
    466467       
    467     delete apimsg;
     468//    delete apimsg;
    468469    return;
    469470  }
     
    480481    ERRCLog(param.name, "No Data Payload in SendMessage. We will not process this further");
    481482    delete apimsg;
     483    if (r_entry)
     484      param.rt.unlock(r_key);
    482485    return;
    483486  }
     
    490493    ERRCLog(param.name, "Not allowed to send messages with GIST Hop Count = 0. We will not process this further.");
    491494    delete apimsg;
     495    if (r_entry)
     496      param.rt.unlock(r_key);
    492497    return;
    493498  }
     
    514519      // create new routingentry (as a querier)
    515520      r_entry= new routingentry(false);
    516            
     521      if (param.addresses.addr_is(src, AddressList::HomeAddr_P)) {
     522        r_entry->set_local_src(src);
     523      } else {
     524        uint32_t pref = IPV6_PREFER_SRC_COA;
     525        hostaddress *laddr = param.addresses.get_src_addr(dst, &pref);
     526        DLog(param.name,"Selecting Address: " << src << ", " << *laddr << param.addresses.addr_is(*laddr, AddressList::HAAddr_P) << param.addresses.addr_is(src, AddressList::HAAddr_P));
     527        if (param.addresses.addr_is(*laddr, AddressList::HAAddr_P))
     528          laddr = param.addresses.get_first(AddressList::AltHAAddr_P, src.is_ipv4());
     529        //cout << *laddr << endl;
     530        r_entry->set_local_src(*laddr);
     531      }
     532
     533      apimsg->set_local_addr(r_entry->local_src->copy());
     534
    517535      // set it to qn_awaiting_response
    518536      r_entry->state=qn_awaiting_response;
     
    546564      // create new routingentry (as querier)
    547565      r_entry= new routingentry(false);
    548            
     566      if (param.addresses.addr_is(src, AddressList::HomeAddr_P)) {
     567        r_entry->set_local_src(src);
     568      } else {
     569        uint32_t pref = IPV6_PREFER_SRC_COA;
     570        hostaddress *laddr = param.addresses.get_src_addr(dst, &pref);
     571        r_entry->set_local_src(*laddr);
     572      }
     573
     574      apimsg->set_local_addr(r_entry->local_src->copy());
     575   
    549576      // set it to qn_awaiting_response
    550577      r_entry->state=qn_awaiting_response;
     
    582609    // save IP TTL for any Messages sent on behalf of this SendMessage
    583610    r_entry->ip_ttl = apimsg->get_ip_ttl();
     611
     612    apimsg->set_local_addr(r_entry->local_src->copy());
    584613       
    585614    switch (r_entry->state)
     
    853882        // apimsg will be deleted in calling method anyway
    854883       
     884        if (r_entry)
     885          param.rt.unlock(r_key);
     886        delete apimsg;
    855887        return;
    856888      }
     
    861893      peer->set_rao(param.rt.get_rao(r_key->nslpid));
    862894      DLog(param.name, "Set RAO value to the one of the NSLP (we know it for sure)");
    863            
    864       uint16 outgoinginterface = mymri->get_local_if();
    865            
    866       if (!outgoinginterface)
    867       {
    868         DLog(param.name, "Lookup of outgoing interface failed (this would certainly also affect the flow's routing). TP modules may use any interface.");
    869       }
    870       else
    871       {
    872         peer->set_if_index(outgoinginterface);
    873         DLog(param.name, "Set request for outgoing interface index " << outgoinginterface << " for GIST Query");
    874       }
    875895
    876896      // send it to signaling
    877897      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     898      sigmsg->set_local_addr(r_entry->local_src->copy());
    878899      sigmsg->set_req(peer, reqpdu);
    879900      sigmsg->send_or_delete();
  • ntlp/branches/20090723-multicast/src/ntlp_statemodule_data.cpp

    r4108 r4212  
    8888  mri* mymri= apimsg->get_mri()->copy();
    8989 
    90   nli* own_nli= build_local_nli(mymri->get_ip_version());
     90  nli* own_nli= build_local_nli(mymri->get_ip_version(), destnli->get_if_address());
    9191  own_nli->set_ip_ttl(apimsg->get_ip_ttl());
    9292   
     
    118118    if (r_entry->is_responding_node())
    119119      sigmsg->set_useexistconn();
     120    sigmsg->set_local_addr(r_entry->local_src->copy());
     121    param.rt.unlock(&myrkey);
    120122  }
    121123  else
     
    153155 
    154156  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
     157  sigmsg->set_local_addr(r_entry->local_src->copy());
    155158
    156159  // Build a DATA Message
     
    166169  mri* mymri=r_key->mr->copy();
    167170   
    168   nli* own_nli=build_local_nli(mymri->get_ip_version(), r_entry);
     171  nli* own_nli=build_local_nli(mymri->get_ip_version(), r_entry->nl->get_if_address(), r_entry);
    169172   
    170173  own_nli->set_ip_ttl(r_entry->ip_ttl);
     
    225228
    226229    SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
     230    sigmsg->set_local_addr(r_entry->local_src->copy());
    227231   
    228232    // Build a DATA Message
     
    349353    if (r_entry->timer_type_3 != queue_poll) {
    350354      DLog(param.name, "Deliberately stopped timer, ignoring");
     355      param.rt.unlock(r_key);
    351356      return;
    352357    }
  • ntlp/branches/20090723-multicast/src/ntlp_statemodule_main.cpp

    r4108 r4212  
    4747#include "ntlp_global_constants.h"
    4848#include "ntlp_error.h"
     49#ifdef USE_FLOWINFO
     50#include "flowinfo.h"
     51#endif
     52
     53#include "rfc5014_hack.h"
    4954
    5055#include <sstream>
     
    7176
    7277StatemoduleParam::StatemoduleParam(routingtable& rt,
    73                                    nli& localnliv4,
    74                                    nli& localnliv6,
     78                                   nli &nli_tmpl,
     79                                   AddressList &addresses,
     80                                   Flowinfo* fi_service,
    7581                                   secretmanager& secrets,
    7682                                   NSLPtable& nslptable,
     
    8187    qaddr_int(message::qaddr_coordination_internal), ///< queue for self messages
    8288    rt(rt),                                ///< routing table
    83     localnliv4(localnliv4),
    84     localnliv6(localnliv6),
     89    nli_tmpl(nli_tmpl),
     90    addresses(addresses),
     91    fi_service(fi_service),
    8592    secrets(secrets),
    8693    nslptable(nslptable),
     
    165172
    166173
     174
     175
    167176/**
    168177 *  called to process message
     
    170179void Statemodule::handleInternalMessage(message *msg)
    171180{
    172   switch (msg->get_type())
     181    switch (msg->get_type())
    173182    {
    174183    // internal message from signaling (message from IP network)
     
    234243          } // end if timermsg
    235244         } break;
     245
     246#ifdef USE_FLOWINFO
     247        case message::type_mobility:
     248        {
     249          // -----------------------
     250          MobilityMsg *mobmsg= dynamic_cast<MobilityMsg*>(msg);
     251          if (mobmsg)
     252          {
     253            // =====================================================
     254            process_mobility_msg(mobmsg); ///< process timer messages
     255            // =====================================================
     256          }
     257          else
     258          {
     259            Log(ERROR_LOG,LOG_ALERT, param.name,
     260                "Cannot cast message from "
     261                << msg->get_qaddr_name() << " of " << msg->get_type_name() << " to MobilityMsg");
     262           
     263            delete msg;
     264          } // end if mobmsg
     265        }
     266        break;
     267#endif
    236268
    237269        // everything else is handled by default
     
    392424
    393425
    394 
     426/**
     427 * process mobility events dispatched from the Flowinfoservice
     428 * @param mobmsg -- the message to process
     429 */
     430void
     431Statemodule::process_mobility_msg(MobilityMsg* mobmsg)
     432{
     433  Flowstatus *fs = mobmsg->get_flowstatus();
     434
     435  switch (fs->type) {
     436  case Flowstatus::fs_home:
     437  {
     438    // Send a NetworkNotification to all registered NSLPs
     439    api_iter cur = param.nslptable.nslptable.begin();
     440    while (cur != param.nslptable.nslptable.end()) {
     441      mri* mymri = fs->orig_mri.copy();
     442      APIMsg* msg = new APIMsg;
     443       
     444      msg->set_source(message::qaddr_coordination);
     445       
     446      msg->set_networknotification((*cur).first, 0, mymri, APIMsg::route_changed_status_home_binding, 0);
     447       
     448      msg->send_to((*cur).second);
     449       
     450      EVLog(param.name, color[yellow] << "NetworkNotification passed to NSLP instance at address "<< (*cur).second << ": " << msg->get_error_str(APIMsg::route_changed_status_home_binding) << color[off]);
     451
     452      cur++;
     453    }
     454    break;
     455  }
     456  case Flowstatus::fs_normal:
     457  {
     458    // Send a NetworkNotification to all registered NSLPs
     459    api_iter cur = param.nslptable.nslptable.begin();
     460    while (cur != param.nslptable.nslptable.end()) {
     461      mri* mymri = fs->orig_mri.copy();
     462      APIMsg* msg = new APIMsg;
     463       
     464      msg->set_source(message::qaddr_coordination);
     465       
     466      msg->set_networknotification((*cur).first, 0, mymri, APIMsg::route_changed_status_binding, 0);
     467       
     468      msg->send_to((*cur).second);
     469       
     470      EVLog(param.name, color[yellow] << "NetworkNotification passed to NSLP instance at address "<< (*cur).second << ": " << msg->get_error_str(APIMsg::route_changed_status_binding) << color[off]);
     471
     472      cur++;
     473    }
     474    break;
     475  }
     476  default:
     477    break;
     478  }
     479
     480  delete mobmsg; 
     481}
    395482
    396483/**
     
    401488 */
    402489nli*
    403 Statemodule::build_local_nli(uint8 ip_version, routingentry* re)
    404 {
    405   nli* mynl = NULL;
    406    
    407   if (ip_version == 4) mynl = param.localnliv4.copy();
    408   if (ip_version == 6) mynl = param.localnliv6.copy();
    409 
    410   uint32 rs_validity_time= gconf.getpar<uint32>(gistconf_rs_validity_time);
    411 
    412   if (re) rs_validity_time= re->rs_validity_time;
    413 
    414   mynl->set_rs_validity_time(rs_validity_time);
     490Statemodule::build_local_nli(uint8 ip_version, const netaddress &dest, routingentry* re)
     491{
     492  nli *mynl;
     493  uint32 rs_validity_time= re ? re->rs_validity_time : gconf.getpar<uint32>(gistconf_rs_validity_time);
     494
     495  if (re) {
     496    mynl = param.nli_tmpl.copy2(*re->local_src);
     497    mynl->set_rs_validity_time(rs_validity_time);
     498  } else {
     499    uint32_t pref = IPV6_PREFER_SRC_COA;
     500    netaddress *src = param.addresses.get_src_addr(dest, &pref);
     501    mynl = param.nli_tmpl.copy2(*src);
     502  }
     503
    415504
    416505  return mynl;
     
    11871276  }
    11881277
    1189   nli* mynl = build_local_nli(ip_version, NULL);
     1278  netaddress na(*peer);
     1279  nli* mynl = build_local_nli(ip_version, na);
    11901280
    11911281  ntlp::error* errpdu = new ntlp::error(mynl, errobj);
     
    12191309  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    12201310  sigmsg->set_req(target, errpdu);
     1311  sigmsg->set_local_addr(mynl->get_if_address().copy());
    12211312  sigmsg->send_or_delete();
    12221313
     
    14531544Statemodule::is_local_address(const hostaddress &addr)
    14541545{
    1455   typedef hostaddresslist_t::const_iterator addr_citer;
    1456 
    1457   addr_citer begin, end;
    1458  
    1459   if ( addr.is_ipv4() ) {
    1460     begin = gconf.getparref< hostaddresslist_t >(gistconf_localaddrv4).begin();
    1461     end = gconf.getparref< hostaddresslist_t >(gistconf_localaddrv4).end();
    1462   } else if ( addr.is_ipv6() ) {
    1463     begin = gconf.getparref< hostaddresslist_t >(gistconf_localaddrv6).begin();
    1464     end = gconf.getparref< hostaddresslist_t >(gistconf_localaddrv6).end();
    1465   }
    1466  
    1467   for ( addr_citer i = begin; i != end; i++ )
    1468     if ( *i == addr )
    1469       return true;
    1470  
    1471   return false;
     1546    netaddress na(addr);
     1547    return param.addresses.addr_is(na, AddressList::ConfiguredAddr_P);
    14721548}
    14731549
  • ntlp/branches/20090723-multicast/src/ntlp_statemodule_querier.cpp

    r4108 r4212  
    130130    }
    131131
    132     // include local Interface to allow tp_queryencap to bind specifically to it
     132/*
     133 * XXXMOB: This is mostly useless
     134 *
    133135    outgoinginterface = refmri->get_local_if();
    134136    if (!outgoinginterface)
     
    141143      DLog(param.name, "Set request for outgoing interface index " << outgoinginterface << " for GIST Query");
    142144    }
     145 */
    143146  }
    144147
     
    161164
    162165  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
     166  sigmsg->set_local_addr(r_entry->local_src->copy());
    163167   
    164168  DLog(param.name, "Setting Port and Protocol");
     
    221225
    222226  // let dedicated function build our NLI
    223   nli* mynli = build_local_nli(mymri->get_ip_version(), r_entry);
     227  nli* mynli = build_local_nli(mymri->get_ip_version(),
     228      refmri->get_downstream()?refmri->get_destaddress():refmri->get_sourceaddress(), r_entry);
    224229
    225230  DLog(param.name, "Built Local NLI");
     
    725730  // construct CONFIRM with copies of objects in response, but no stackprop and NLI of US
    726731   
    727   nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry);
     732  nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry->nl->get_if_address(), r_entry);
    728733  mynli->set_ip_ttl(r_entry->ip_ttl);
    729734
     
    743748  // put into signaling message
    744749  sigmsg->set_req(target, conf);
     750  sigmsg->set_local_addr(r_entry->local_src->copy());
    745751  sigmsg->send_or_delete();
    746752}
     
    763769  // construct signaling message
    764770  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
     771  sigmsg->set_local_addr(r_entry->local_src->copy());
    765772
    766773  appladdress* target = NULL;
     
    843850
    844851  // construct CONFIRM with copies of objects in response, but no data and NLI of US
    845   nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry);
     852  nli* mynli = build_local_nli(r_key->mr->get_ip_version(), r_entry->nl->get_if_address(), r_entry);
    846853  mynli->set_ip_ttl(r_entry->ip_ttl);
    847854
     
    901908    if (r_entry->timer_type != inactive_qnode) {
    902909      DLog(param.name, "Deliberately stopped timer, ignoring");
     910      param.rt.unlock(r_key);
    903911      return;
    904912    }
     
    945953    if (r_entry->timer_type_2 != noresponse) {
    946954      DLog(param.name, "Deliberately stopped timer, ignoring");
     955      param.rt.unlock(r_key);
    947956      return;
    948957    }
     
    955964      EVLog(param.name, color[magenta] << "NoResponse Timer went off" << color[off]);
    956965      // NoResponse timer retransmits Queries until state changes to rn_established and timer is stopped
    957       if (! r_entry->retry_limit_reached() )
     966      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)))
    958969      {
    959970        if (r_entry->dmode) {
     
    10361047    if (r_entry->timer_type_2 != refresh_qnode) {
    10371048      DLog(param.name, "Deliberately stopped timer, ignoring");
     1049      param.rt.unlock(r_key);
     1050      return;
     1051    }
     1052
     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))) {
     1055      DLog(param.name, "Local Address no longer owned - let it die!");
     1056      param.rt.unlock(r_key);
    10381057      return;
    10391058    }
     
    10671086           
    10681087      param.rt.unlock(r_key);       
     1088    } else {
     1089      param.rt.unlock(r_key);
    10691090    }
    10701091  }
  • ntlp/branches/20090723-multicast/src/ntlp_statemodule_responder.cpp

    r4108 r4212  
    4444#include "authorized_peer_db.h"
    4545
     46#include "rfc5014_hack.h"
     47
    4648#include "gist_conf.h"
    4749
     
    7476  // create new entry for routing table (we are a responder now)
    7577  routingentry* r_entry = new routingentry(true);
     78  const hostaddress *src = dynamic_cast<const hostaddress *>(own_addr);
     79  if (src->is_ip_unspec()) {
     80    DLog(param.name, "Couldn't determine own address on receive - using reverse lookup");
     81    uint32_t pref = IPV6_PREFER_SRC_COA;
     82    src = param.addresses.get_src_addr(*(dynamic_cast<const hostaddress *>(peer)), &pref);
     83  }
     84  r_entry->set_local_src(*src->copy());
    7685
    7786  // save potentially present NAT Traversal payload in routing entry
     
    9099  r_entry->qrc=new querycookie(*(query_pdu->get_querycookie()));
    91100
    92   // if we have a NAT traversal object, use information from it
    93   // for cookie generation etc. otherwise the cookie cannot be validated
    94   // properly
    95   if (r_entry->nattrav)
    96   {
    97           const nli* nto_nli= r_entry->nattrav->get_nli();
    98           // save a copy of the NLI carried in the NAT Traversal object
    99           if ( nto_nli )
    100           {
    101                 r_entry->nl= new nli( *nto_nli );
    102                 DLog(param.name, "Using NLI from NAT traversal object, i/f address: " << nto_nli->get_if_address());
    103           }
    104   }
    105   else
     101  nli* query_nli= query_pdu->get_nli();
     102  if (query_nli)
    106103  { // use NLI from the PDU
    107           // save NLI
    108           r_entry->nl= new nli(*query_pdu->get_nli());
     104    // save NLI
     105    r_entry->nl= new nli(*query_nli);
     106    // 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);
    109109  }
    110110
     
    113113  {
    114114          const peer_identity* pid= r_entry->nl->get_pi();
    115           if (pid && (*pid == *(param.localnliv4.get_pi())) || *pid == *(param.localnliv6.get_pi()))
     115          if ( pid && (*pid == *(param.nli_tmpl.get_pi())) )
    116116          { // peer id from query nli is the same as ours, this is usually an error
    117117                  WLog(param.name,"Detected Query coming from myself, will be ignored and dropped to avoid loopback to myself.");
     
    282282                   
    283283  // save Query Cookie
    284   r_entry->qrc=new querycookie(*(query_pdu->get_querycookie()));
     284  r_entry->qrc= new querycookie(*(query_pdu->get_querycookie()));
    285285                   
    286286  // save newer Stackprop
     
    318318  const respcookie* echoed_resp_cookie= cnfpdu->get_respcookie();
    319319
     320  // we must use the original NLI from the query since the one in Confirm is untranslated
     321 
     322  nli* translated_nli= echoed_resp_cookie ? echoed_resp_cookie->get_nli() : NULL;
     323  // peer_nli is the NLI for responder cookie verification
     324  const nli* peer_nli= translated_nli ? translated_nli : cnfpdu->get_nli();
     325
    320326  bool respcookie_matched= false;
    321327  // evaluate Responder Cookie in CONFIRM
    322   if (echoed_resp_cookie && (respcookie_matched= evaluate_resp_cookie(cnfpdu->get_nli(), r_key, echoed_resp_cookie)) == false)
     328  if (echoed_resp_cookie && (respcookie_matched= evaluate_resp_cookie(peer_nli, r_key, echoed_resp_cookie)) == false)
    323329  {
    324330    WLog(param.name, "Responder Cookie did not match, discarding GIST Confirm");
     
    333339  else
    334340  {
    335     if (echoed_resp_cookie)
    336     {
    337       DLog(param.name, "Responder Cookie matched, processing GIST Confirm");
    338 
    339       if (echoed_resp_cookie->get_if_index() != r_entry->get_incoming_if())
    340       {
    341         WLog(param.name, "Found inconsistency: Responder Cookie indicated that Query used a different interface: old idx="
    342              << r_entry->get_incoming_if() << " new idx=" << echoed_resp_cookie->get_if_index());
    343       }
    344     }
    345 
    346     // For C-Mode first we must check what is required by us, i.e.
    347     // if we require security we have only secure protocols in the proposal
    348     // we must check with the peers policy though
     341          if (echoed_resp_cookie)
     342          {
     343                  DLog(param.name, "Responder Cookie matched, processing GIST Confirm");
     344                 
     345                  if (echoed_resp_cookie->get_if_index() != r_entry->get_incoming_if())
     346                  {
     347                          ILog(param.name, "Responder Cookie indicated that Query used a different interface: old idx="
     348                               << r_entry->get_incoming_if() << " new idx=" << echoed_resp_cookie->get_if_index());
     349                  }
     350          }
     351 
     352
     353          if (translated_nli && r_entry->translated_nli && (*translated_nli != *(r_entry->translated_nli)))
     354          {
     355                  WLog(param.name,"Translated NLI differs between initial query and routing state entry");
     356          }
     357          delete translated_nli;
     358         
     359          // For C-Mode first we must check what is required by us, i.e.
     360          // if we require security we have only secure protocols in the proposal
     361          // we must check with the peers policy though
    349362    if (echoed_resp_proposal)
    350363    {
     
    358371        // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    359372        SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     373        sigmsg->set_local_addr(r_entry->local_src->copy());
    360374        sigmsg->set_trm(peer->copy());     
    361375        sigmsg->send_or_delete();
     
    394408      // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    395409      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     410      sigmsg->set_local_addr(r_entry->local_src->copy());
    396411      sigmsg->set_trm(peer->copy());       
    397412      sigmsg->send_or_delete();
     
    440455    nslpdata* moddata = NULL;
    441456    moddata = r_entry->mod_data;
     457    r_entry->mod_data = NULL;
    442458    if (moddata) delete moddata;
    443459   
     
    464480          // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    465481          SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     482          sigmsg->set_local_addr(r_entry->local_src->copy());
    466483          sigmsg->set_trm(peer->copy());           
    467484          sigmsg->send_or_delete();
     
    524541
    525542  // MUST CHECK with different NLI and r_key if NTO is present...
     543  // we need to store the translated NLI in our routing entry, because
     544  // responses have to go back to this external NAT address
     545  nli* translated_nli= responder_cookie->get_nli();
     546  nli* peer_nli= translated_nli ? translated_nli : cnfpdu->get_nli();
     547
    526548  // evaluate Responder Cookie in CONFIRM
    527   bool rsp_cookie_matched = evaluate_resp_cookie(cnfpdu->get_nli(), r_key, responder_cookie);
     549  bool rsp_cookie_matched = evaluate_resp_cookie(peer_nli, r_key, responder_cookie);
    528550
    529551  // is Responder Cookie valid?
     
    550572 
    551573  routingentry* r_entry= new routingentry(true);
     574  const hostaddress *src = dynamic_cast<const hostaddress *>(own_addr);
     575  if (src->is_ip_unspec()) {
     576    DLog(param.name, "Couldn't determine own address on receive - using reverse lookup");
     577    uint32_t pref = IPV6_PREFER_SRC_COA;
     578    src = param.addresses.get_src_addr(*(dynamic_cast<const hostaddress *>(peer)), &pref);
     579  }
     580  r_entry->set_local_src(*src->copy());
     581
     582  if (translated_nli)
     583  {       // please note that translated_nli will be freed by rentry destructor
     584          r_entry->translated_nli= peer_nli;
     585  }
    552586
    553587  bool ma_reuse= false;
     
    614648  if (responder_cookie->get_transparent_data())
    615649  {
    616           uint32 bytes_read= 0;
    617           IEErrorList errorlist;
    618           nattraversal* nat_trav_obj= new nattraversal;
    619           NetMsg* tmpbuf= new NetMsg(responder_cookie->get_transparent_data(),
    620                                      responder_cookie->get_transparent_data_len(),
    621                                      false);
    622           nat_trav_obj->deserialize(*tmpbuf, IE::protocol_v1, errorlist, bytes_read, false);
    623           if (errorlist.is_empty() == false)
    624           {
    625                   ERRLog(param.name,"parse error while getting NTO from responder cookie - this is an implementation error");
    626           }
    627           else
    628           {
    629                   // save the nat traversal object
    630                   r_entry->nattrav= nat_trav_obj;
    631           }
    632           delete tmpbuf;
     650          r_entry->nattrav= responder_cookie->get_nto(peer_nli->get_serialized_size(IE::protocol_v1));
    633651  }
    634652
     
    655673      // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    656674      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     675      sigmsg->set_local_addr(r_entry->local_src->copy());
    657676      sigmsg->set_trm(peer->copy());       
    658677      sigmsg->send_or_delete();
     
    691710    // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    692711    SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     712    sigmsg->set_local_addr(r_entry->local_src->copy());
    693713    sigmsg->set_trm(peer->copy());         
    694714    sigmsg->send_or_delete();
     
    867887    // create new entry as a copy (copy connection settings, objects which are stored while issuing refresh query)
    868888    routingentry* new_entry = new routingentry(*r_entry);
     889    const hostaddress *src = dynamic_cast<const hostaddress *>(own_addr);
     890    if (src->is_ip_unspec()) {
     891      DLog(param.name, "Couldn't determine own address on receive - using reverse lookup");
     892      uint32_t pref = IPV6_PREFER_SRC_COA;
     893      src = param.addresses.get_src_addr(*(dynamic_cast<const hostaddress *>(peer)), &pref);
     894    }
     895    r_entry->set_local_src(*src->copy());
    869896
    870897    // match it with all the new data delivered from peer
     
    934961      // Now send a SigTrm to Signaling to tear down TPoverTCP (or whatever else)
    935962      SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
     963      sigmsg->set_local_addr(r_entry->local_src->copy());
    936964      sigmsg->set_trm(peer->copy());       
    937965      sigmsg->send_or_delete();
     
    11031131
    11041132  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP();
     1133  sigmsg->set_local_addr(r_entry->local_src->copy());
    11051134 
    11061135  // Generate our target address
     
    11221151  // use the saved nli (in latestate case, we would not repeat but have a PDU)
    11231152  // this is ususally the case only when we have stored state and no_confirm timer went off
     1153  // note that in case of gist aware-NAT traversal an initial query carries the translated NLI (external addr)
     1154  // and further refreshing queries carry untranslated addresses (local/internal addr)
     1155  // for MA lookup we'll always use the untranslated NLI
    11241156  nli* qnli= pdu ? pdu->get_nli() : r_entry->nl;
    11251157
    1126   // override in case of NAT traversal, use info from NAT traversal object
    1127   if (r_entry->nattrav)
    1128           qnli= r_entry->nl;
    11291158  if (qnli)
    11301159  {
     
    11611190
    11621191    response_dest= new appladdress;
    1163        
     1192 
     1193    // for NAT traversal scenario: must try translated NLI information first
     1194    if (r_entry->translated_nli)
     1195    { // must sent back to NAT public address
     1196        response_dest->set_ip(r_entry->translated_nli->get_if_address());
     1197    }
     1198    else
    11641199    if (pdu)
    1165     {
     1200    { // should use most current information from PDU
    11661201      if (pdu->get_nli())
    11671202        response_dest->set_ip(pdu->get_nli()->get_if_address());
    11681203    }
    11691204    else
    1170     {
     1205    { // use what we already know from routing entry
    11711206      if (r_entry->nl)
    11721207        response_dest->set_ip(r_entry->nl->get_if_address());
     
    11991234  }
    12001235
    1201   nli* nl = build_local_nli(mr->get_ip_version(), r_entry);
     1236  netaddress na(*response_dest);
     1237  nli* nl = build_local_nli(mr->get_ip_version(), na, r_entry);
    12021238
    12031239  // test if we have a saved nat traversal object (NTO)
    12041240  nattraversal* nto = dynamic_cast<nattraversal*>(r_entry->nattrav);
    12051241  NetMsg* ntobuf_p= NULL;
    1206   // put NTO as transparent data into hash if present
     1242  // put NLI and NTO as transparent data into hash if present
    12071243  if (nto)
    12081244  {
    1209           uint32 ntobuf_size= nto->get_serialized_size(IE::protocol_v1);
     1245          if (!qnli)
     1246                  ERRLog(param.name,"Querier NLI not present when trying to insert it into NAT traversal object");
     1247
     1248          // put NLI first, because we need it for validation
     1249          uint32 ntobuf_size= qnli->get_serialized_size(IE::protocol_v1) + nto->get_serialized_size(IE::protocol_v1);
    12101250          ntobuf_p= new NetMsg(ntobuf_size);
    12111251          // should be serialized including the common object header
    12121252          uint32 written= 0;
     1253          // write NLI first
     1254          qnli->serialize(*ntobuf_p, IE::protocol_v1, written);
     1255          // write NTO as second object
    12131256          nto->serialize(*ntobuf_p, IE::protocol_v1, written);
    12141257  }
     
    12381281      DLog(param.name, "There will be no repetitions of this Response, cleaning replacement NSLP data");
    12391282      delete (r_entry->mod_data);
    1240      
     1283      r_entry->mod_data = NULL;
     1284
    12411285      mydata = NULL;
    12421286    }
     
    15221566  // check for any transparent objects carried in the responder cookie
    15231567  // and make sure that we don't read behind the end of the buffer
    1524   NetMsg* transparent_data_msgbuf= ( (td_len > 0) && (4+2+2+td_len < responder_cookie->get_size()) ) ?
     1568  NetMsg* transparent_data_msgbuf= ( (td_len > 0) && ( (uint32)(td_len+4+2+2) < responder_cookie->get_size()) ) ?
    15251569          new NetMsg(responder_cookie->get_transparent_data(), td_len, false) : NULL;
    15261570
     
    15711615    if (r_entry->timer_type != expire_rnode) {
    15721616      DLog(param.name, "Deliberately stopped timer, ignoring");
     1617      param.rt.unlock(r_key);
    15731618      return;
    15741619    }
  • ntlp/branches/20090723-multicast/src/pdu/mri_le.cpp

    r4108 r4212  
    310310
    311311
    312 
    313 
    314 //virtual function which allows each MRI subtype to return a local interface address
    315 uint16
    316 mri_looseend::get_local_if() const
    317 {
    318 
    319     // a local IF number of '0' will cause the Framework not to try to bind to a specific interface - unnecessary here!
    320      return 0;
    321    
    322 }
    323 
    324 
    325 
    326 
    327 //virtual function inverting direction flag, Responder nodes stores MRI with inverted direction
     312// virtual function inverting direction flag, Responder nodes stores MRI with inverted direction
    328313void mri_looseend::invertDirection() {
    329314
  • ntlp/branches/20090723-multicast/src/pdu/mri_pc.cpp

    r4108 r4212  
    3131#include <iomanip>
    3232#include <string>
    33 #include <cerrno>
    34 
    35 #ifndef NSIS_OMNETPP_SIM
    36 // this will NOT be included in the OMNeT++ simulation, but otherwise
    37   #include <net/if.h>
    38   #include <linux/types.h> // in case that this one is not included in netlink.h
    39   #include <linux/netlink.h>
    40   #include <linux/rtnetlink.h>
    41 #endif // end ifndef NSIS_OMNETPP_SIM
    4233
    4334#include "logfile.h"
    4435#include "mri_pc.h"
    45 
    46 #include "readnl.h"
    4736
    4837using namespace ntlp;
     
    611600
    612601
    613 #ifndef NSIS_OMNETPP_SIM
    614 
    615 /**
    616  * Returns the interface number the kernel would use for this MRI.
    617  *
    618  * This depends on the Direction flag (upstream/downstream).
    619  *
    620  * TODO: Review and cleanup necessary.
    621  */
    622 uint16
    623 mri_pathcoupled::get_local_if() const
    624 {
    625     //#######################################################################
    626     //
    627     // Query the kernel via RTNetlink socket with RTM_GET_ROUTE
    628     //
    629     // currently, this fails for IPv4, no idea as to why
    630     //
    631     //#######################################################################
    632 
    633     // Buffer for error messages, used by the strerror_r() calls below.
    634     char msg_buf[1024];
    635 
    636     // We must decide whether IPv4 or IPv6 is used
    637     bool ipv6 = destaddress.is_ipv6();
    638 
    639 
    640     // 2 sockaddr_in6?
    641     struct in6_addr dstaddr, srcaddr;
    642     struct in_addr dstaddr4, srcaddr4;
    643    
    644     // Netlink Message header plus RTNetlink Message Header plus 1024byte data
    645     struct {
    646         struct nlmsghdr n;
    647         struct rtmsg r;
    648         char data[1024];
    649     } req;
    650 
    651     // Struct rtattr
    652     struct rtattr *attr;
    653     struct rtattr *attr2;
    654 
    655    
    656     // int outgoinginterface
    657     uint16 outgoinginterface = 0;
    658 
    659    
    660     // enable this routine here
    661     if (true) {
    662 
    663         // OPEN a RTNETLINK SOCKET
    664        
    665         int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
    666         if (sock < 0) {
    667             strerror_r(errno, msg_buf, sizeof msg_buf);
    668             ERRCLog("mri_pathcoupled::get_local_if()",
    669                         "error opening Netlink socket: " << msg_buf);
    670         }       
    671 
    672         // if IPv6
    673 
    674         if (ipv6) {
    675 
    676             if (flags & Direction) {
    677                 sourceaddress.get_ip(dstaddr);
    678                 destaddress.get_ip(srcaddr);
    679             } else {
    680                 destaddress.get_ip(dstaddr);
    681                 sourceaddress.get_ip(srcaddr);
    682             }           
    683 
    684             memset(&req, 0, sizeof(req));
    685             req.n.nlmsg_len =
    686                 NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.r))) +
    687                 RTA_LENGTH(sizeof(dstaddr)) + RTA_LENGTH(sizeof(srcaddr));
    688             req.n.nlmsg_flags = NLM_F_REQUEST;
    689             req.n.nlmsg_type = RTM_GETROUTE;
    690             req.r.rtm_family = AF_INET6;
    691             req.r.rtm_dst_len = 128;
    692             req.r.rtm_src_len = 128;
    693 
    694             attr = (rtattr*) (((char *) &req) + NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.r))));
    695             attr->rta_type = RTA_DST;
    696             attr->rta_len = RTA_LENGTH(sizeof(dstaddr));
    697 
    698             memcpy(RTA_DATA(attr), &dstaddr, sizeof(dstaddr));
    699 
    700 
    701             attr2 = (rtattr*) (((char*) &req) + NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.r))) + attr->rta_len);
    702             attr2->rta_type = RTA_SRC;
    703             attr2->rta_len = RTA_LENGTH(sizeof(srcaddr));
    704 
    705 
    706             memcpy(RTA_DATA(attr2), &srcaddr, sizeof(srcaddr));
    707 
    708 
    709             // Send to Kernel
    710 
    711              /*Send the message*/
    712 
    713             if (send(sock, &req, req.n.nlmsg_len, 0) < 0) {
    714                 strerror_r(errno, msg_buf, sizeof msg_buf);
    715                 ERRCLog("mri_pathcoupled::get_local_if()",
    716                         "error sending Netlink message: " << msg_buf);
    717                 close(sock);
    718             }
    719 
    720             char* returnbuf = new char[NL_BUFSIZE];
    721 
    722             int read = readnl(sock, returnbuf);
    723 
    724             if (read < 0) return 0;
    725 
    726             nlmsghdr* nlhdrp = (struct nlmsghdr *)returnbuf;
    727 
    728             rtmsg* rtmsg = (struct rtmsg*)NLMSG_DATA(nlhdrp);
    729            
    730 
    731             // Iterate through data area serachin
    732 
    733             rtattr* attrp = RTM_RTA(rtmsg);
    734             uint32 attrlen = RTM_PAYLOAD(nlhdrp);
    735 
    736             for( ; RTA_OK(attrp, attrlen); attrp = RTA_NEXT(attrp, attrlen) ){
    737 
    738                
    739                 if ((attrp->rta_type) == RTA_OIF) {
    740                    
    741                     char* ifname= new char[IF_NAMESIZE];
    742                     if_indextoname(*(int *)RTA_DATA(attrp), ifname);
    743 
    744                     Log(EVENT_LOG, LOG_NORMAL, "mri_pathcoupled",  "Kernel decided the outgoing interface index should be " << *(int *)RTA_DATA(attrp) << ", interface Name " << ifname);
    745                
    746                     outgoinginterface=*(int *)RTA_DATA(attrp);
    747                     delete ifname;
    748                 }
    749 
    750 
    751             }
    752 
    753 
    754 
    755 
    756         } //end if IPv6
    757         else
    758         {
    759 
    760 
    761             //cout << "IPv4 used, query for IPv4" << endl;
    762 
    763 
    764             if (flags & Direction) {
    765 
    766             sourceaddress.get_ip(dstaddr4);
    767             destaddress.get_ip(srcaddr4);
    768 
    769             } else {
    770 
    771             destaddress.get_ip(dstaddr4);
    772             sourceaddress.get_ip(srcaddr4);
    773 
    774             }
    775 
    776             //cout << "Got socket addresses from data structures" << endl;
    777            
    778             memset(&req, 0, sizeof(req));
    779             req.n.nlmsg_len =
    780                 NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.r))) +
    781                 RTA_LENGTH(sizeof(dstaddr4)) + RTA_LENGTH(sizeof(srcaddr4));
    782             req.n.nlmsg_flags = NLM_F_REQUEST;
    783             req.n.nlmsg_type = RTM_GETROUTE;
    784             req.r.rtm_family = AF_INET;
    785             req.r.rtm_dst_len = 12;
    786             req.r.rtm_src_len = 12;
    787 
    788             attr = (rtattr*) (((char *) &req) + NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.r))));
    789             attr->rta_type = RTA_DST;
    790             attr->rta_len = RTA_LENGTH(sizeof(dstaddr4));
    791 
    792             memcpy(RTA_DATA(attr), &dstaddr4, sizeof(dstaddr4));
    793 
    794             attr2 = (rtattr*) (((char*) &req) + NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.r))) + RTA_LENGTH(sizeof(dstaddr4)));
    795             attr2->rta_type = RTA_SRC;
    796             attr2->rta_len = RTA_LENGTH(sizeof(srcaddr4));
    797 
    798 
    799             memcpy(RTA_DATA(attr2), &srcaddr4, sizeof(srcaddr4));
    800 
    801 
    802             // Send to Kernel
    803 
    804             if (send(sock, &req, req.n.nlmsg_len, 0) < 0) {
    805                 strerror_r(errno, msg_buf, sizeof msg_buf);
    806                 ERRCLog("mri_pathcoupled::get_local_if()",
    807                         "error sending Netlink message: " << msg_buf);
    808                 close(sock);
    809             }
    810 
    811             char* returnbuf = new char[NL_BUFSIZE];
    812 
    813             int read = readnl(sock, returnbuf);
    814 
    815             if (read <0 ) return 0;
    816 
    817             nlmsghdr* nlhdrp = (struct nlmsghdr *)returnbuf;
    818 
    819             rtmsg* rtmsg = (struct rtmsg*)NLMSG_DATA(nlhdrp);
    820            
    821             // Iterate through data area serachin
    822             rtattr* attrp = RTM_RTA(rtmsg);
    823             uint32 attrlen = RTM_PAYLOAD(nlhdrp);
    824 
    825             for( ; RTA_OK(attrp, attrlen); attrp = RTA_NEXT(attrp, attrlen) ){
    826 
    827                 if ((attrp->rta_type) == RTA_OIF) {
    828                    
    829                     char* ifname= new char[IF_NAMESIZE];
    830                     if_indextoname(*(int *)RTA_DATA(attrp), ifname);
    831 
    832                     Log(EVENT_LOG, LOG_NORMAL, "mri_pathcoupled",  "Linux Kernel decided the outgoing interface index should be " << *(int *)RTA_DATA(attrp) << ", interface Name " << ifname);
    833                
    834                     outgoinginterface=*(int *)RTA_DATA(attrp);
    835                     delete ifname;
    836                 }
    837 
    838 
    839             }
    840 
    841             if (returnbuf) delete returnbuf;
    842             close(sock);
    843 
    844             if (!outgoinginterface) {
    845                
    846                 Log(EVENT_LOG, LOG_NORMAL, "mri_pathcoupled", "Linux Kernel was unable to provide a outgoing interface for this flow, taking default route.");
    847 
    848             }
    849         }
    850     }
    851    
    852     return outgoinginterface;
    853 }
    854 
    855 #else
    856 // this is only included in the OMNeT++ Simulation
    857 uint16
    858 mri_pathcoupled::get_local_if() const
    859 {
    860   return 0; // not really relevant yet
    861 }
    862 
    863 #endif // ifndef NSIS_OMNETPP_SIM
    864 
    865602
    866603// Invert direction flag; responder nodes stores MRI with inverted direction
  • ntlp/branches/20090723-multicast/src/pdu/nattraversal.cpp

    r4108 r4212  
    4747 */
    4848
    49 void
    50 natinfo::clear() {
    51         for (translated_object_list_t::iterator cit= translated_object_list.begin(); cit != translated_object_list.end(); cit++)
    52         {
    53                 delete (*cit);
    54         };
    55         translated_object_list.clear();
    56 }
    57 
    58 
    59 natinfo::natinfo(const natinfo& nat_info) {
    60         for (translated_object_list_t::const_iterator cit= nat_info.translated_object_list.begin();
    61              cit != nat_info.translated_object_list.end(); cit++)
    62         {
    63                 if (*cit)
    64                         add(*(*cit)); // add copies the object
    65         };
    66 }
    67 
    68 
    69 natinfo&
    70 natinfo::operator=(const natinfo& nat_info)
    71 {
    72         clear();
    73         for (translated_object_list_t::const_iterator cit= nat_info.translated_object_list.begin();
    74              cit != nat_info.translated_object_list.end(); cit++)
    75         {
    76                 if (*cit)
    77                         add(*(*cit)); // add copies the object
    78         };
    79         return *this;
    80 }
    81 
    82 bool
    83 natinfo::operator==(const natinfo& ni) const
    84 {
    85         if (count() != ni.count())
    86                 return false;
    87 
    88         for (int i= 0; i<count(); i++)
    89         {
    90                 if ( translated_object_list[i]==NULL || ni.translated_object_list[i]==NULL
    91                      ||
    92                      *translated_object_list[i] != *(ni.translated_object_list[i]) )
    93                         return false;
    94         }
    95         return true;
    96 }
    97 
    98 
    99 uint16
    100 natinfo::length() const
    101 {
    102         uint16 len= 0;
    103         for (translated_object_list_t::const_iterator cit= translated_object_list.begin();
    104              cit != translated_object_list.end();
    105              cit++)
    106         {
    107                 len += (*cit)->get_serialized_size(IE::protocol_v1);
    108         }
    109         return len;
    110 }
    111 
    112 
    113 const nli*
    114 natinfo::get_nli() const
    115 {
    116         for (translated_object_list_t::const_iterator cit= translated_object_list.begin(); cit != translated_object_list.end(); cit++)
    117         {
    118                 if (*cit)
    119                 {
    120                         if ( (*cit)->is_nli() )
    121                                 return reinterpret_cast<const ntlp::nli*>(*cit);
    122                 }
    123         }
    124         return NULL;
    125 }
    12649
    12750
     
    244167        tmp= msg.decode16();
    245168
    246 
    247     // read NLI infos
    248    
    249     natinfo nat_info_temp;
    250 
    251     // iterate over profile_count to read whole NAT information
     169    // read opaque NAT infos
     170    // iterate over NAT count to read all NAT information objects
    252171    for (i=0; i<nat_count; i++) {
    253         nat_info_temp.clear();
    254 
    255172        // read length of total opaque information fields of NAT i:
    256173        len = msg.decode16();
    257         //      uint count = 1;
    258         uint32 objbread = 0;
    259         uint32 tmpbread = 1;
    260         uint32 objpos = msg.get_pos();
    261        
    262        
    263         IE* tmpie = NULL;
    264         ntlp_object* tmpobj = NULL;
    265         known_ntlp_object* tmpknown = NULL;
    266 
    267         // iterate through Higher Level Information
    268         while ((objbread<len) && (tmpbread!=0) && (msg.get_pos() < ielen)) {
    269          
    270                 // deserialize next NTLP object
    271                 tmpie = NTLP_IEManager::instance()->deserialize(msg,cat_known_pdu_object,cod,errorlist,tmpbread,false); //skip == false??
    272                 objbread += tmpbread;
    273                
    274                 if (tmpie) 
    275                         tmpobj = dynamic_cast<ntlp_object*>(tmpie);
    276                 else {
    277                         tmpobj = NULL;
    278                         ERRCLog(methodname, "could not cast to ntlp_object");
    279                 }
    280 
    281                 if (tmpobj) {
    282                         tmpknown = dynamic_cast<known_ntlp_object*>(tmpobj);
    283                         if (tmpknown) {
    284                                 nat_info_temp.add(*tmpknown);
    285                         }
    286                         else {
    287                                 DLog(methodname, "unknown object in opaque information list, ignoring");
    288                         } // end if tmpknown
    289                 }
    290                 else {         
    291                         // TODO: for further extension, if the opaque information
    292                         // is not the ntlp_obj, it should be skip anyway
    293                        
    294                         if (tmpie) delete tmpie;
    295                         // do logging and recover
    296                         ERRLog(methodname, "no NTLP object deserialized from IE");
    297                         if (!skip) {
    298                                 msg.set_pos(resume);
    299                                 return this;
    300                         } // end if not skip
    301                 } // end if tmpobj
    302                 // setting position of next object
    303                 objpos += tmpbread;             
    304         } // end while objbread<len
     174
     175        // allocate new NetMsg buffer and don't copy contents!
     176        NetMsg* netmsgbuf= new NetMsg(msg.get_buffer()+msg.get_pos(), len, false);
     177        // move forward within the message
     178        msg.set_pos_r(len);
     179
     180        natinfo nat_info_temp;
     181        nat_info_temp.set(netmsgbuf);
     182
     183        // this will actually create a copy of the natinfo netmsg buffer
     184        push_natinfo(nat_info_temp);
    305185
    306186        // handle padding, initial length field of NAT info is 16-bit
     
    311191                padbytes--;
    312192        }
    313        
    314         push_natinfo(nat_info_temp);
    315193    } // end for iterating over NAT info objects
    316194
     
    331209// special serialization function with the ability to omit the TLV header
    332210void nattraversal::serializeEXT(NetMsg& msg, coding_t cod, uint32& wbytes, bool header) const {
    333         const char *const methodname= "nattraversal::serialize()";
    334 
    335         uint32 nto_length = get_serialized_size(cod) - (header ? 0 : header_length); // includes object header
     211    const char *const methodname= "nattraversal::serialize()";
     212
     213    // get_serialized_size includes object header
     214    uint32 nto_length = get_serialized_size(cod) - (header ? 0 : header_length);
     215
    336216    DLog(methodname,"should be of length " << nto_length);
    337217    // check arguments and IE state
     
    341221    if (header)
    342222    {
    343             encode_header_ntlpv1(msg, nto_length - header_length);
    344             DLog(methodname, "Header encoded, 4 byte, bytes left in NetMsg: " << msg.get_bytes_left());
    345     }
    346     DLog(methodname, "Begin of actual serialization");
     223            encode_header_ntlpv1(msg, nto_length - header_length); // length should exclude the header
     224            DLog(methodname, "Common Object header encoded (objlen=" << nto_length - header_length << " bytes), 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     225    }
     226    DLog(methodname, "Begin of object content serialization");
    347227       
    348228    // encode mri length (get_serialized_size currently returns byte size INCLUDING TLV header, we must subtract 1 word = 4 byte)
     
    398278            msg.encode16(info_len);
    399279           
    400             uint32 tmp_wbytes = 0;
    401             for (uint16 j=0; j<nat_information[i].size(); j++) {
    402                     if (nat_information[i].get(j))
    403                     {
    404                             try
    405                             {
    406                                     nat_information[i].get(j)->serialize(msg,cod,tmp_wbytes);
    407                             }
    408                             catch (IEError& e)
    409                             {
    410                                     ERRCLog(methodname,"while processing " << nat_information[i].get(j)->get_ie_name() << ":" << e.getstr());
    411                             }
    412                             catch(...)
    413                             {
    414                                     throw;
    415                             }
    416                     } // end if
    417 
    418                     // encode padding: each opaque information field is zero-padded
    419                     // to the next 32-bit word boundary if necessary.
    420            
    421             } // end for j
    422 
     280            if (nat_information[i].get())
     281            {
     282                    msg.copy_from(nat_information[i].get()->get_buffer(), msg.get_pos(), info_len);
     283                    msg.set_pos_r(info_len);
     284            }
    423285            // must pad two length bytes + NAT info part to a 32-bit boundary
    424286            uint8 padbytes= (2 + info_len) % 4;
     
    469331            // length info for all translated info of NAT #i
    470332            size+= 16;
    471             uint16 natinfosize= 0;
    472333            // translated objects of NAT#i
    473             for (uint16 j= 0; j<nat_information[i].size(); j++)
    474             {
    475                     // the length of opaque information and the padding to a 32bit alignment
    476                     natinfosize= nat_information[i].get(j)->get_serialized_size(cod);
    477                     size+= natinfosize * 8;
    478             }
     334            // the length of opaque information and the padding to a 32bit alignment
     335            uint16 natinfosize= nat_information[i].length();
     336            size+= natinfosize * 8;
     337            //DLog("nattraversal::get_serialized_size()","nat info objects size " << natinfosize << " bytes");
     338
    479339            // add padding if necessary
    480340            // starting from length field, padding up to the next 32-bit boundary
     
    520380                //DLog("nattraversal::operator==","No of NAT info ok.");
    521381
    522                 const known_ntlp_object* ni1;
    523                 const known_ntlp_object* ni2;
    524 
    525382                for (uint32 i=0; i<nat_information.size(); i++) {
    526383                        // translated objects of NAT#i
    527                         if (nat_information[i].size() != nto->nat_information[i].size())
     384                        if (nat_information[i].length() != nto->nat_information[i].length())
    528385                                return false;
    529386
    530                         for (uint16 j= 0; j<nat_information[i].size(); j++)
    531                         {
    532                                 ni1= nat_information[i].get(j);
    533                                 ni2= nto->nat_information[i].get(j);
    534                                 if (ni1 == NULL || ni2 == NULL || *ni1 != *ni2)
    535                                         return false;
    536                                
    537                         } // end for
     387                        // size of both buffers is equal due to precondition
     388                        if (memcmp(nat_information[i].get()->get_buffer(), nto->nat_information[i].get()->get_buffer(),nat_information[i].length()))
     389                                return false;
    538390                } // end for NAT info #i
    539391
     
    551403    if (name && (*name!=0)) os<<name<< endl;
    552404
    553     uint j=0;
    554405    uint i=0;
    555406       
     
    574425    }
    575426    os << endl;
    576    
     427
    577428    // iterate nat_information, 
    578     for (i=0; i<nat_information.size(); i++) {
    579            
    580             for (j=0; j<nat_information[i].size(); j++) {
    581                     nat_information[i].get(j)->print(os,level,indent);
    582             }
    583             os << endl;
     429    for (i=0; i<nat_information.size(); i++) {     
     430            os << *(nat_information[i].get()) << endl;
    584431    }
    585432   
  • ntlp/branches/20090723-multicast/src/pdu/nattraversal.h

    r4108 r4212  
    4646
    4747/**
    48  * list of translated NTLP objects / information per NAT
     48 * list of translated NTLP objects / information per NAT,
     49 * this information is opaque and specific per NAT
    4950 **/
    5051class natinfo {
    5152 public:
    5253        /// constructor
    53         natinfo() {};
     54        natinfo() : netmsgbuf(NULL) {};
     55
    5456        /// copy constructor
    55         natinfo(const natinfo& nat_info);
     57        natinfo(const natinfo& nat_info) {
     58                netmsgbuf= nat_info.get() ? new NetMsg(*nat_info.get()) : NULL;
     59        }
     60
    5661        /// destructor
    5762        ~natinfo() { clear(); }
    5863
    5964        // assignment operator
    60         natinfo& operator=(const natinfo& nat_info);
    61 
    62         bool operator==(const natinfo& ni) const;
    63 
    64         /// add a copy of of the NTLP object to the translated NAT information
    65         void add(const known_ntlp_object& obj) { translated_object_list.push_back( obj.copy() ); };
    66 
    67         /// get NAT info object at certain index
    68         const known_ntlp_object* get(unsigned int index) const { return translated_object_list.at(index); };
    69 
    70         /// get back number of NAT info objects
    71         unsigned int size() const { return translated_object_list.size(); };
    72 
    73         /// remove all objects from list
    74         void clear();
    75 
    76         uint16 count() const { return translated_object_list.size(); };
    77 
    78         /// get back NLI object if exists, NULL otherwise
    79         const nli* get_nli() const;
    80 
    81         uint16 length() const;
     65        natinfo& operator=(const natinfo& nat_info) {
     66                if (netmsgbuf) { delete netmsgbuf; }
     67                netmsgbuf= nat_info.get() ? new NetMsg(*nat_info.get()) : NULL;
     68                return *this;
     69        }
     70
     71        bool operator==(const natinfo& ni) const {
     72                if (netmsgbuf==NULL && ni.get()==NULL)
     73                        return true;
     74                else
     75                if (netmsgbuf!=NULL && ni.get()!=NULL)
     76                        return *netmsgbuf == *(ni.get());
     77                else
     78                        return false;
     79        }
     80
     81        /// add a copy of the translated NAT information
     82        void set(const NetMsg& givennetmsgbuf) {
     83                if (netmsgbuf) { delete netmsgbuf; }
     84                netmsgbuf= new NetMsg(givennetmsgbuf);
     85        }
     86
     87        /// add the netmsg as translated NAT information (object will be taken over!)
     88        void set(NetMsg* givennetmsgbuf) {
     89                if (netmsgbuf) { delete netmsgbuf; }
     90                netmsgbuf= givennetmsgbuf;
     91        }
     92       
     93        /// get opaque NAT info back (as NetMsg buffer)
     94        const NetMsg* get() const { return netmsgbuf; }
     95
     96        /// remove all contents
     97        void clear() { delete netmsgbuf; }
     98
     99        uint16 length() const { return netmsgbuf ? netmsgbuf->get_size() : 0; }
    82100
    83101private:
    84         typedef std::vector<known_ntlp_object *> translated_object_list_t;
    85 
    86         translated_object_list_t translated_object_list;
    87 
     102        NetMsg* netmsgbuf;
    88103};
    89104
     
    155170
    156171        const mri* get_embedded_mri() const { return embedded_mri; }
    157         const nli* get_nli() const {
    158                 if (!nat_information.empty())
    159                         return nat_information.front().get_nli();
    160                 else
    161                         return NULL;
    162         }
    163 
    164172
    165173 private:
    166174        typedef std::vector<natinfo> nat_information_t;
    167175
    168         // the vector holding NLI information (one information object per traversed NAT)
     176        // the vector holding NAT specific opaque information
     177        // (one information object per traversed NAT)
    169178        nat_information_t nat_information;
    170179       
     
    210219        // This is the one mighty constructor, via which the object SHOULD be built programmatically!
    211220        inline
    212         nattraversal (const mri* mr, std::vector <natinfo> nat_information, std::vector <uint16> translated_object_types):
     221        nattraversal (const mri* mr, nat_information_t nat_information, std::vector <uint16> translated_object_types):
    213222                known_ntlp_object(NatTraversal, Mandatory),
    214223                nat_information(nat_information),
  • ntlp/branches/20090723-multicast/src/pdu/nli.cpp

    r3674 r4212  
    114114} // end copy
    115115
     116nli* nli::copy2(netaddress if_address) const {
     117        nli* sh = NULL;
     118        catch_bad_alloc(sh =  new nli(*this));
     119        sh->if_address = if_address;
     120        sh->ip_version= if_address.is_ipv6() ? 6 : 4;
     121        return sh;
     122} // end copy
     123
    116124nli*
    117125nli::deserialize(NetMsg& msg, coding_t cod, IEErrorList& errorlist, uint32& bread, bool skip) {
  • ntlp/branches/20090723-multicast/src/pdu/nli.h

    r4108 r4212  
    122122        virtual nli* new_instance() const;
    123123        virtual nli* copy() const;
     124        nli* copy2(netaddress if_address) const;
    124125        virtual nli* deserialize(NetMsg& msg, coding_t cod, IEErrorList& errorlist, uint32& bread, bool skip = true);
    125126        virtual void serialize(NetMsg& msg, coding_t cod, uint32& wbytes) const;
  • ntlp/branches/20090723-multicast/src/pdu/ntlp_errorobject.cpp

    r3674 r4212  
    707707      flags        == eo->flags
    708708      &&
    709       (embedded_sessionid != NULL && eo->embedded_sessionid !=NULL && (*embedded_sessionid == *(eo->embedded_sessionid))
     709      ((embedded_sessionid != NULL && eo->embedded_sessionid !=NULL && (*embedded_sessionid == *(eo->embedded_sessionid)))
    710710       || (embedded_sessionid == NULL && eo->embedded_sessionid == NULL))
    711711      &&
    712       (embedded_mri != NULL && eo->embedded_mri != NULL && *embedded_mri == *(eo->embedded_mri)
     712      ((embedded_mri != NULL && eo->embedded_mri != NULL && *embedded_mri == *(eo->embedded_mri))
    713713       || (embedded_mri == NULL && eo->embedded_mri==NULL))
    714714      &&
     
    723723      ovi_offset == eo->ovi_offset
    724724      &&
    725       (ovi_object != NULL && eo->ovi_object !=NULL && (*ovi_object == *(eo->ovi_object))
     725      ((ovi_object != NULL && eo->ovi_object !=NULL && (*ovi_object == *(eo->ovi_object)))
    726726       || (ovi_object == NULL && eo->ovi_object == NULL))
    727727      &&
    728       ( debugcomment != NULL && eo->debugcomment != NULL && (strcmp(debugcomment,eo->debugcomment)==0) || (debugcomment == NULL && eo->debugcomment == NULL));
     728      ((debugcomment != NULL && eo->debugcomment != NULL && (strcmp(debugcomment,eo->debugcomment)==0))
     729       || (debugcomment == NULL && eo->debugcomment == NULL));
    729730  }
    730731  else
  • ntlp/branches/20090723-multicast/src/pdu/ntlp_object.cpp

    r4108 r4212  
    154154        if (bytes_left<header_length) {
    155155                catch_bad_alloc(iee = new IEMsgTooShort(protocol_v1,category,saved_pos));
    156                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << " , category " << category << ", position " << saved_pos);
     156                ERRLog("NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << " , category " << category << ", position " << saved_pos << ", bytes left=" << bytes_left << " required:" << header_length);
    157157                errorlist.put(iee);
    158158                msg.set_pos(saved_pos);
     
    164164        } catch(IEError& ignored) {
    165165                catch_bad_alloc(iee = new IETooBigForImpl(protocol_v1,category,saved_pos));
    166                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << " , category " << category << ", position " << saved_pos);
     166                ERRLog("NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << " , category " << category << ", position " << saved_pos);
    167167                errorlist.put(iee);
    168168                msg.set_pos(saved_pos);
     
    172172        if (bytes_left<ielen) {
    173173                catch_bad_alloc(iee = new IEMsgTooShort(protocol_v1,category,saved_pos));
    174                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << " , category " << category << ", position " << saved_pos);
     174                ERRLog("NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << " , category " << category << ", position " << saved_pos << ", required: " << ielen << " bytes, available: " << bytes_left << " bytes");
    175175                errorlist.put(iee);
    176176                msg.set_pos(saved_pos);
     
    184184        if (t!=type) {
    185185                catch_bad_alloc(iee = new IEWrongType(protocol_v1,category,saved_pos));
    186                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << ", " << t << (skip ?  ", skipping IE." : "."));
     186                ERRLog("NTLP_object", "known_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << protocol_v1 << ", " << t << (skip ?  ", skipping IE." : "."));
    187187                if (skip) {
    188188                  bread = ielen;
     
    225225  {
    226226    IEWrongLength err(protocol_v1,category,type,255,msg.get_pos());
    227     Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "known_ntlp_object::encode_header_ntlpv1(): IE " << get_ie_name()
     227    ERRLog("NTLP_object", "known_ntlp_object::encode_header_ntlpv1(): IE " << get_ie_name()
    228228        << ", error " << err.getstr() << ", length " << len << ", object is not aligned to 32-bit word boundary");
    229229    throw err;
     
    234234  {
    235235    IEMsgTooShort err(protocol_v1,category,msg.get_pos());
    236     Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "known_ntlp_object::encode_header_ntlpv1(): IE " << get_ie_name()
     236    ERRLog("NTLP_object", "known_ntlp_object::encode_header_ntlpv1(): IE " << get_ie_name()
    237237        << ", error " << err.getstr() << ", required: " << objlen << " bytes, available: " << msg.get_bytes_left() << " bytes");
    238238    throw err;
     
    280280        IEError* iee = NULL;
    281281        catch_bad_alloc(iee = new IEWrongLength(cod,category,type,255,msgpos));
    282         Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", get_ie_name() << "::deserialize(): error, " << iee->getstr() << ", coding " << cod << ", type " << (int)type << ", wrong_length " << len << ", position " << msgpos << (skip ? ", skipping IE." : "." ));
     282        ERRLog("NTLP_object", get_ie_name() << "::deserialize(): error, " << iee->getstr() << ", coding " << cod << ", type " << (int)type << ", wrong_length " << len << ", position " << msgpos << (skip ? ", skipping IE." : "." ));
    283283        elist.put(iee);
    284284        msg.set_pos(resume);
     
    337337        if (bytes_left<header_length) {
    338338                catch_bad_alloc(iee = new IEMsgTooShort(cod,category,saved_pos));
    339                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "raw_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << cod << ", category " << category << ", position " << saved_pos);
     339                ERRLog("NTLP_object", "raw_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << cod << ", category " << category << ", position " << saved_pos);
    340340                errorlist.put(iee);
    341341                return NULL;
     
    346346        } catch(IEError& ignored) {
    347347                catch_bad_alloc(iee = new IETooBigForImpl(cod,category,saved_pos));
    348                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "raw_ntlp_object::deserialize: error " << iee->getstr() << ", coding " << cod << ", category " << category << ", position " << saved_pos);
     348                ERRLog("NTLP_object", "raw_ntlp_object::deserialize: error " << iee->getstr() << ", coding " << cod << ", category " << category << ", position " << saved_pos);
    349349                errorlist.put(iee);
    350350                msg.set_pos(saved_pos);
     
    356356        if (bytes_left<ielen) {
    357357                catch_bad_alloc(iee = new IEMsgTooShort(cod,category,saved_pos));
    358                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "raw_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << cod << ", category " << category << ", position " << saved_pos);
     358                ERRLog("NTLP_object", "raw_ntlp_object::decode_header_ntlpv1: IE " << get_ie_name() << ", error " << iee->getstr() << ", coding " << cod << ", category " << category << ", position " << saved_pos);
    359359                errorlist.put(iee);
    360360                return NULL;
     
    369369                return this;
    370370        } else {
    371           Log(ERROR_LOG,LOG_CRIT, "NTLP_object", "raw_ntlp_object::deserialize: Unable to allocate content buffer");
     371          ERRCLog("NTLP_object", "raw_ntlp_object::deserialize: Unable to allocate content buffer");
    372372          throw IEError(IEError::ERROR_NO_MEM);
    373373          return NULL;
     
    395395        if (coding!=cod) {
    396396                IEError err(IEError::ERROR_CODING);
    397                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "raw_ntlp_object::serialize(), error " << err.getstr() << ", coding " << cod);
     397                ERRLog("NTLP_object", "raw_ntlp_object::serialize(), error " << err.getstr() << ", coding " << cod);
    398398                throw err;
    399399        } // end if coding
     
    401401        if (msg.get_bytes_left()<buflen) {
    402402                IEMsgTooShort err(cod,category,msg.get_pos());
    403                 Log(ERROR_LOG,LOG_NORMAL, "NTLP_object", "raw_ntlp_object::serialize(), error " << err.getstr() << " Required additional " << buflen);
     403                ERRLog("NTLP_object", "raw_ntlp_object::serialize(), error " << err.getstr() << " Required additional " << buflen);
    404404                throw err;
    405405        } // end if not enough memory
  • ntlp/branches/20090723-multicast/src/pdu/ntlp_pdu.cpp

    r4108 r4212  
    467467        // Query message or Q-mode Data message, or was clear on a Query
    468468        // message.
    469         if ( (!c_flag) && ((type == known_ntlp_pdu::Query))
     469        if (  ((!c_flag) && ((type == known_ntlp_pdu::Query)))
    470470            ||
    471              ( c_flag && (type != known_ntlp_pdu::Query) && (type != known_ntlp_pdu::Data) )
     471              ( c_flag && (type != known_ntlp_pdu::Query) && (type != known_ntlp_pdu::Data))
    472472           )
    473473        {
  • ntlp/branches/20090723-multicast/src/pdu/resp_cookie.cpp

    r4108 r4212  
    249249
    250250
     251nli*
     252respcookie::get_nli() const
     253{
     254  uint16 transparent_data_len= get_transparent_data_len();
     255  uchar* transparent_data= get_transparent_data();
     256
     257  // first extract the NLI from transparent data if present 
     258  if (transparent_data)
     259  {
     260          // perform a sanity check first (transparent data len must be smaller than resp cookie length)
     261          // if someone messed with the length value in transparent data
     262          if (transparent_data_len < buf_length)
     263          {
     264                  uint32 bytes_read= 0;
     265                  IEErrorList errorlist;
     266                  // data is not copied into NetMsg buffer
     267                  NetMsg tmpbuf(transparent_data, transparent_data_len, false);
     268                  nli* nli_obj= new nli;
     269                  nli_obj->deserialize(tmpbuf, IE::protocol_v1, errorlist, bytes_read, false);
     270                  if (errorlist.is_empty() == false)
     271                  { // parse error
     272                          ERRLog("respcookie::get_nli()","parse error while getting NLI from responder cookie - this is an implementation error or some attacker messed with it");
     273                          return NULL;
     274                  }
     275                  else // parsing successful
     276                          return nli_obj;
     277          }
     278  }
     279
     280  return NULL;
     281}
     282
     283
     284nattraversal*
     285respcookie::get_nto(uint16 byteoffset) const
     286{
     287  uint16 transparent_data_len= get_transparent_data_len();
     288  uchar* transparent_data= get_transparent_data();
     289
     290  if (transparent_data && byteoffset < transparent_data_len)
     291  {
     292          uint32 bytes_read= 0;
     293          IEErrorList errorlist;
     294          nattraversal* nat_trav_obj= new nattraversal;
     295          NetMsg tmpbuf(transparent_data+byteoffset, transparent_data_len-byteoffset, false);
     296          nat_trav_obj->deserialize(tmpbuf, IE::protocol_v1, errorlist, bytes_read, false);
     297          if (errorlist.is_empty() == false)
     298          {
     299                  ERRLog("respcookie::get_nto()","parse error while getting NTO from responder cookie - this is an implementation error");
     300                  return NULL;
     301          }
     302          else
     303          {
     304                  return nat_trav_obj;
     305          }
     306  }
     307  return NULL;
     308}
     309
    251310//@}
    252311
  • ntlp/branches/20090723-multicast/src/pdu/resp_cookie.h

    r4108 r4212  
    2727//
    2828// ===========================================================
     29#ifndef _NTLP__RESPCOOKIE_H_
     30#define _NTLP__RESPCOOKIE_H_
     31
    2932#include "ntlp_object.h"
    3033#include "address.h"
    3134#include "protlib_types.h"
    3235
     36#include "nli.h"
     37#include "nattraversal.h"
    3338
    34 #ifndef _NTLP__RESPCOOKIE_H_
    35 #define _NTLP__RESPCOOKIE_H_
    3639
    3740
     
    6669
    6770  // decode transparent data length field (16bit) expressed as number of bytes, located after the generation num and interface id
    68   uint16 get_transparent_data_len() const { return buf ? ntohs(*(reinterpret_cast<uint16*>(buf+sizeof(uint32)+sizeof(uint16)))) : 0; }
     71  uint16 get_transparent_data_len() const { return (buf && buf_length>=8) ? ntohs(*(reinterpret_cast<uint16*>(buf+sizeof(uint32)+sizeof(uint16)))) : 0; }
    6972
    7073  // return start of the transparent data part or 0 if not present
     
    144147  virtual ~respcookie() { delete buf; }
    145148
     149  nli*  get_nli() const;
     150  nattraversal* get_nto(uint16 byteoffset) const;
    146151
    147152};
  • ntlp/branches/20090723-multicast/src/routingtable.cpp

    r4108 r4212  
    581581  }
    582582
     583  remove_entry(rt_it);
     584
     585  unlocktable(); // <=<=< UNLOCK <=<=<
     586 
     587  return true;
     588}
     589
     590void
     591routingtable::remove_entry(rt_iter &it)
     592{
     593  routingentry* rt_entry;
     594  if (it == rtable.end())
     595    return;
     596
     597  rt_entry= it->second;
     598
    583599  // mark entry dead
    584600  rt_entry->state=dead;
     
    587603  rt_entry->dmode=true;
    588604  rt_entry->secure=false;
    589      
     605
     606  const routingkey* key = &it->first;
    590607  DLog(classname, "Deleted Routing Key w/ Session-ID "<< ((key->sid) ? key->sid->to_string() : "NULL") );
    591608
    592609  // delete entry in routing table
    593   rtable.erase(*key);
     610  rtable.erase(it);
    594611  status();
    595   // delete key;
    596   if (!table_already_locked)
    597     unlocktable(); // <=<=< UNLOCK <=<=<
    598  
    599   return true;
    600612}
    601613
     
    628640  }
    629641
    630   // mark entry dead
    631   rt_entry->state=dead;
    632   rt_entry->lock=false;
    633   // switch to D-Mode, unsecure
    634   rt_entry->dmode=true;
    635   rt_entry->secure=false;
    636  
     642  remove_entry(rt_it);
     643
     644  delete key;
    637645  DLog(classname, "Destroyed Routing Key, key is unusable");
    638    
    639   // delete entry in key map and routing data!
    640   rtable.erase(*key);
    641   status();
    642   delete key;
    643646 
    644647  unlocktable(); // <=<=< UNLOCK <=<=<
     
    959962              DLog(classname, "I am QN for this state, going ahead and starting new handshake in QN_AWAITING_RESPONSE (no communication possible)");
    960963
    961               // Make a COPY of the routing entry, invalidate the old one by delete_entry()                             
     964              // Make a COPY of the routing entry, invalidate the old one by remove_entry()
    962965              routingentry* tmpentry = new routingentry(*entry);
    963               // note: routing table has already been locked, do not lock again
    964               delete_entry(key, true);
     966              remove_entry(cur);
     967              // XXX: after removing the entry from the table the iterator is no longer valid!
     968              //      starting from the begining again, though this is not 100% correct, as the
     969              //      cur++ at the bottom will make us start from begining+1
     970              //      It seems unlikely, however, that we have more than one match in a hash_map
     971              //      so this whole while-loop is probably bogus anyway.  For the moment this is
     972              //      good enough.
     973              cur = rtable.begin();
    965974              add(key, tmpentry);
    966975              if (entry) delete entry;
     
    9971006              DLog(classname, "I am RN, I cannot re-install state, even though it was requested simply going to 'DEAD'");
    9981007             
    999               delete_entry(key, true);
     1008              remove_entry(cur);
     1009              // XXX: see above
     1010              cur = rtable.begin();
    10001011            }
    10011012          } // endif urgency
     
    10041015            DLog(classname, color[red] << "No immediate re-installation is requested, just killing the state" << color[off]);
    10051016           
    1006             delete_entry(key, true);
     1017            remove_entry(cur);
     1018            // XXX: see above
     1019            cur = rtable.begin();
    10071020          }
    10081021        }
     
    10641077        ERRCLog(classname, "There is a key for which there is no routing state anymore?!?!");
    10651078    } // end if key matches
     1079
     1080    // XXX: in case we just killed the last one
     1081    if (cur == rtable.end())
     1082        break;
     1083
    10661084    cur++;
    10671085  } // end while
  • ntlp/branches/20090723-multicast/src/routingtable.h

    r4108 r4212  
    266266  {
    267267    if (nattrav) delete nattrav;
     268    if (translated_nli) delete translated_nli;
    268269    if (nl) delete nl;
    269270    if (qrc) delete qrc;
     
    273274    if (sp) delete sp;
    274275    if (sc) delete sc; 
     276    if (local_src) delete local_src;
    275277  } // end destructor
    276278   
     
    279281    dataqueue.clear();
    280282    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;
    281284    dmode=n.dmode;
    282285    secure=n.secure;
     
    287290    if (n.tmppeer) tmppeer=n.tmppeer->copy(); else tmppeer = NULL;
    288291    if (n.tmppdu) tmppdu=n.tmppdu->copy(); else tmppdu = NULL;
    289     if (n.mod_data) mod_data=n.mod_data->copy();
     292    if (n.mod_data) mod_data=n.mod_data->copy(); else mod_data = NULL;
    290293    if (n.sp) sp = n.sp->copy(); else sp = NULL;
    291294    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;
    292296    ip_ttl=n.ip_ttl;
    293297    ghc=n.ip_ttl;
     
    339343  const char* get_state_name() const { return (state<rt_state_max) ? statestring[state] : "state variable invalid - internal error"; };
    340344
     345  void set_local_src(const hostaddress src) {
     346          //cout << "XXXYYY: " << src << endl;
     347        local_src = src.copy();
     348  }
     349
    341350  /// print routing entry as string
    342351  string to_string() const;
     
    347356  /// saved NAT Traversal object
    348357  nattraversal* nattrav;
     358  ///
     359  nli* translated_nli;
    349360 
    350361  /// role of the node
     
    358369  /// and provides DMode Adressing (Port is Well-Known)
    359370  nli* nl;
     371
     372  // The local address that was used as source to create this entry
     373  hostaddress *local_src;
    360374   
    361375  /// store different states
     
    633647  void unlocktable();
    634648
     649  /// delete entry, still accessible via sii-handle
     650  void remove_entry(rt_iter &it);
     651
    635652  void inc_sii_handle() { sii_counter++;
    636653    // do not use 0 as valid handle
     
    669686routingentry::routingentry(bool is_responder) :
    670687    nattrav(NULL),
     688    translated_nli(NULL),
    671689    is_responder(is_responder),
    672690    dmode(true),
  • ntlp/branches/20090723-multicast/src/signalingmodule_ntlp.cpp

    r4108 r4212  
    5151#include "logfile.h"
    5252#include "ntlp_proto.h"
     53#include "rfc5014_hack.h"
    5354
    5455#ifndef NSIS_OMNETPP_SIM
     
    8182 * SignalingNTLPParam constructor, take over parameters for Signaling Module
    8283 * @param pm -- The Protocol map containing pointers to all TP Modules in use
    83  * @param localnliv4 -- A NLI describing the peer, contains the IPv4 address which is to be sent to peers for contacting this peer
    84  * @param localnliv6 -- A NLI describing the peer, contains the IPv6 address which is to be sent to peers for contacting this peer
     84 * @param addresses -- an Address List containing IP addresses of the node
    8585 * @param nslptable -- The table holding the addresses of registered NSLP clients
    8686 * @param well_known_port -- The UDP Well-Known Port of GIST
     
    9191 */
    9292SignalingNTLPParam::SignalingNTLPParam(protocol_map_t pm,
    93                                        nli& localnliv4,
    94                                        nli& localnliv6,
    95                                        //const appladdress& deforig,
     93                                       nli &nli_tmpl,
     94                                       AddressList &addresses,
    9695                                       NSLPtable& nslptable,
    9796                                       uint16 well_known_port,
     97                                       Flowinfo *fi_service,
    9898                                       uint32 sleep_time,
    9999                                       bool see, bool sre
     
    101101  : ThreadParam(sleep_time,"GIST Signaling"),
    102102    protomap(pm),
    103     localnliv4(localnliv4),
    104     localnliv6(localnliv6),
    105     //default_originator(deforig),
     103    nli_tmpl(nli_tmpl),
     104    addresses(addresses),
    106105    source(message::qaddr_signaling),
    107106    send_error_expedited(see),
    108107    send_reply_expedited(sre),
    109108    nslptable(nslptable),
    110     well_known_port(well_known_port)
     109    well_known_port(well_known_port),
     110    fi_service(fi_service)
    111111{
    112112} // end constructor
     
    128128        subtype(ignore), err(SignalingNTLP::error_ok),
    129129        pdu(NULL), peer(NULL), ownaddr(NULL), encap_pdu(NULL), ref_id(0), confirm(conf),
    130         use_existing_connection(false)
     130        use_existing_connection(false), local_src(NULL)
    131131{}
    132132
     
    137137        if (ownaddr) delete ownaddr;
    138138        if (encap_pdu) delete encap_pdu;
     139        if (local_src) delete local_src;
    139140} // end destructor
    140141
     
    249250  ownaddr = NULL;
    250251  encap_pdu = NULL;
     252  local_src = NULL;
    251253} // end clear_pointers
    252254
     
    319321  : Thread(p),
    320322    param(p),
    321     gistproto(p.default_originator, p.localnliv4, p.localnliv6, p.well_known_port)
     323    gistproto(p.addresses, p.well_known_port)
    322324{
    323325  // register queue
     
    597599        // Implement the relaying if no suitable NSLPID is available on the machine
    598600        uint32 nslpid = result_pdu->get_nslpid();
     601
     602        DLog(param.name, color[blue] << "Incoming message is addressed to NSLP ID " << nslpid);
    599603
    600604        if ((nslpid==0) || (param.nslptable.get_address(nslpid) != message::qaddr_unknown))
     
    713717                 
    714718                  // here we also call the MRI outgoing interface lookup routine to provide us with a outgoing interface index
    715                   sigmsg->set_req(target, result_pdu, 0, result_pdu->get_mri()->get_local_if());
     719                  sigmsg->set_req(target, result_pdu, 0);
    716720                  sigmsg->send_or_delete();
    717721                 
     
    747751          // we should not establish a new connection for sending back an error:
    748752          // either we use the existing one or drop the message
    749           send_tp(netmsg, *(peer->copy()), true);
     753          send_tp(netmsg, *(peer->copy()), 0, true);
    750754        } // end if OK
    751755        if (peer) delete peer;
     
    805809  NTLP::error_t gisterror = NTLP::error_ok;
    806810  appladdress peer;
     811  const hostaddress *laddr;
    807812  known_ntlp_pdu* pdu = NULL;
    808813  NetMsg* netmsg = NULL;
     
    846851          peer = *sigmsg->get_peer();
    847852          pdu = sigmsg->get_pdu();
     853          laddr = sigmsg->get_local_addr();
     854
     855          if (laddr != NULL)
     856            DLog(param.name, "MOBILITY: Sending from:" << *laddr);
    848857
    849858          // add basic header if necessary
    850           if (sigmsg->get_oif())
    851           {
    852               DLog(param.name, color[blue] << "We were indicated to request usage of interface " << sigmsg->get_oif() << color[off]);
    853           }
    854 
    855859          // Log output
    856860          if (pdu->get_sessionid())
     
    876880            // netmsg should not be accessed after this call because it may have been already deleted
    877881            peer.convert_to_ipv6();
    878             sendres = send_tp(netmsg,peer, sigmsg->get_oif(), sigmsg->get_useexistconn());
     882            sendres = send_tp(netmsg, peer, laddr, sigmsg->get_useexistconn());
    879883            if (sendres==error_ok)
    880884            {
     
    905909          pdu = sigmsg->get_pdu();
    906910          peer = *(sigmsg->get_peer());
     911          laddr = sigmsg->get_local_addr();
     912
     913          if (laddr != NULL)
     914            DLog(param.name, "MOBILITY: Sending from:" << *laddr);
    907915
    908916          // Log output
     
    927935            peer.convert_to_ipv6();
    928936            // as a responder we are not allowed to establish any transport connections
    929             sendres= send_tp(netmsg, peer, sigmsg->get_useexistconn());
     937            sendres= send_tp(netmsg, peer, laddr, sigmsg->get_useexistconn());
    930938            if (sendres==error_ok)
    931939            {
     
    10401048 */
    10411049SignalingNTLP::error_t
    1042 SignalingNTLP::send_tp(NetMsg* msg, const appladdress& addr, uint16 oif, bool use_existing_connection)
     1050SignalingNTLP::send_tp(NetMsg* msg, const appladdress& addr, const hostaddress *laddr, bool use_existing_connection)
    10431051{
    10441052  error_t res = error_ok;
     
    10501058    {
    10511059      EVLog(param.name,"Sending msg to Protocol #" << (int) addr.get_protocol() << " (" << addr.get_protocol_name() << ") Dest:" << addr.get_ip_str());
    1052 
    1053       if (oif) DLog(param.name, "send_tp: Request to use specific interface received, index: " << oif);
    10541060
    10551061      // cannot send to unknown address
     
    10631069      // or the TP must ensure that it works on copies of both parameters since they might get freed
    10641070      // soon after this method returns...
    1065       tp->send(msg, addr, use_existing_connection);
     1071      tp->send(msg, addr, use_existing_connection, laddr);
    10661072    } // end try
    10671073    catch(TPError& e)
     
    11721178  } // end switch
    11731179 
    1174   uint8 ip_version = (mr!=0) ? mr->get_ip_version() : (peer->is_ipv4() ? 4 : 6);
    1175 
    1176   nli* mynl = NULL;
    1177 
    1178   if (ip_version == 4)
    1179   {
    1180     mynl = param.localnliv4.copy();
    1181   }
    1182   else
    1183   {
    1184     mynl = param.localnliv6.copy();
    1185   }
    1186 
    1187   ntlp::error* errpdu = new ntlp::error(mynl, errobj);
    1188 
    1189   errpdu->set_hops(1);
    1190 
    11911180  // calculate the address
    11921181  appladdress* target = NULL;
     1182  nli *mynl = NULL;
    11931183
    11941184  // IP source is NOT the last GIST hop
     
    11991189      DLog(param.name, "IP Source is NOT last GIST hop, sending to GIST denoted by NLI");
    12001190      target = new appladdress(pdu->get_nli()->get_if_address(), "udp", param.well_known_port);
     1191      uint32_t pref = IPV6_PREFER_SRC_COA;
     1192      netaddress *src_addr = param.addresses.get_src_addr(
     1193        pdu->get_nli()->get_if_address(), &pref);
     1194      if (src_addr == 0)
     1195      {
     1196        ERRCLog(param.name, "Could not determine source address for " << target << ".  Dropping errormessage: " << pdu);
     1197      }
     1198      mynl = param.nli_tmpl.copy2(*src_addr);
    12011199    }
    12021200    else
    12031201    {
    1204       ERRCLog(param.name, "No valid target address for Error Message found. Dropping errormessage: " << pdu);   
     1202      ERRCLog(param.name, "No valid target address for Error Message found. Dropping errormessage: " << pdu);
    12051203    }   
    12061204  }
     
    12091207    DLog(param.name, "IP Source IS last GIST hop, sending to it.");
    12101208    target = new appladdress(*peer);
     1209    uint32_t pref = IPV6_PREFER_SRC_COA;
     1210    netaddress *src_addr = param.addresses.get_src_addr(*peer, &pref);
     1211    mynl = param.nli_tmpl.copy2(*src_addr);
    12111212    if (target->get_protocol() == prot_query_encap) target->set_protocol(tsdb::get_udp_id());
    12121213    if (target->get_protocol() == tsdb::get_udp_id()) target->set_port(param.well_known_port);
    12131214  }
    1214  
     1215
     1216  ntlp::error* errpdu = new ntlp::error(mynl, errobj);
     1217
     1218  errpdu->set_hops(1);
     1219
    12151220  SignalingMsgNTLP* sigmsg = new SignalingMsgNTLP;
    12161221  sigmsg->set_req(target, errpdu);
     
    12921297    char* returnbuf = new char[NL_BUFSIZE];
    12931298       
    1294     readnl(sock, returnbuf);
     1299    protlib::util::readnl(sock, returnbuf);
    12951300       
    12961301    nlmsghdr* nlhdrp = reinterpret_cast<struct nlmsghdr *>(returnbuf);
     
    13731378    char* returnbuf = new char[NL_BUFSIZE];
    13741379       
    1375     readnl(sock, returnbuf);
     1380    protlib::util::readnl(sock, returnbuf);
    13761381       
    13771382    nlmsghdr* nlhdrp = reinterpret_cast<struct nlmsghdr *>(returnbuf);
  • ntlp/branches/20090723-multicast/src/signalingmodule_ntlp.h

    r4108 r4212  
    3838#include "ntlp_error.h"
    3939#include "ntlp_errorobject.h"
    40 
     40#include "flowinfo.h"
    4141
    4242
     
    6060  const  protocol_map_t protomap;
    6161
    62   nli& localnliv4;
    63   nli& localnliv6;
    64   const  appladdress default_originator;
     62  nli &nli_tmpl;
     63  AddressList &addresses;
    6564  const  message::qaddr_t source;
    6665  const  bool send_error_expedited;
     
    6968  NSLPtable& nslptable;
    7069  uint16 well_known_port;
     70  Flowinfo *fi_service;
    7171
    7272  SignalingNTLPParam(protocol_map_t pm,
    73                      nli& localnliv4,
    74                      nli& localnliv6,
    75                      //const appladdress& deforig,
     73                     nli &nli_tmpl,
     74                     AddressList &addresses,
    7675                     NSLPtable& nslptable,
    7776                     uint16 well_known_port,
     77                     Flowinfo *fi_service= NULL,
    7878                     uint32 sleep_time = ThreadParam::default_sleep_time,
    7979                     bool see = true,
     
    114114
    115115        // returns whether a given address belongs to one of the DRM addresses
     116        // XXXMOB: might be okay for the moment
    116117        bool is_own_address(const hostaddress& ha) const { return gistproto.isown_address(&ha); };
    117118        // return default originator address
    118         const appladdress* default_originator() const { return &param.default_originator; };
     119        // XXXMOB: Not sure we want this anymore.
     120        // const appladdress* default_originator() const { return &param.default_originator; };
    119121
    120122protected:
     
    134136        void send_back_sig_error(error_t err, SignalingMsgNTLP* msg);
    135137        void send_back_confirmation(SignalingMsgNTLP* msg);
    136         error_t send_tp(NetMsg* msg, const appladdress& addr, uint16 oif = 0, bool use_exist_conn= false);
     138        // XXXMOB: Needs originator address arg
     139        error_t send_tp(NetMsg* msg, const appladdress& addr, const hostaddress *laddr = 0, bool use_exist_conn= false);
    137140
    138141        /// Send Error Message to peer, if the error occured in SignalingModule processing
     
    169172        /// set result
    170173        void set_error(SignalingNTLP::error_t r) { err = r; }
    171         /// get outgoing interface
    172         uint16 get_oif() { return oif; }
    173         void set_oif(uint16 iface) { oif = iface; }
    174174        /// get result
    175175        SignalingNTLP::error_t get_error() const { return err; }
     
    212212        bool get_useexistconn() const { return use_existing_connection; };
    213213
     214        void set_local_addr(hostaddress *ls) { local_src = ls; };
     215        hostaddress *get_local_addr() { return local_src; }
     216
    214217private:
    215218        subtype_t subtype;
     
    217220        known_ntlp_pdu* pdu;
    218221        const appladdress* peer;
     222        // XXXMOB: this needs to be used for all messages?
    219223        const appladdress* ownaddr;
    220224        known_ntlp_pdu* encap_pdu;
     
    226230
    227231        bool use_existing_connection;
     232
     233        hostaddress *local_src;
    228234}; // end class SignalingMsg
    229235
  • ntlp/branches/20090723-multicast/test/responder_cookie.cpp

    r4108 r4212  
    119119
    120120  public:
    121         resp_cookie_test() : gcinit(),
    122                              smpar(rt,
    123                                    localnliv4,
    124                                    localnliv6,
     121        resp_cookie_test() : gcinit(),
     122                             addresses(new AddressList()),
     123                             smpar(rt,
     124                                   localnliv4,
     125                                   *addresses,
     126                                   NULL,
    125127                                   secrets,
    126128                                   nslptable,
    127                                    raovec, 
     129                                   raovec,
    128130                                   10),
    129131                             statemod(smpar)
     
    162164        void test_resp_cookie() {
    163165                // test if we have a saved nat traversal object (NTO)
     166                NetMsg opaque_natinfobuf(localnliv4.get_serialized_size(IE::protocol_v1));
     167                uint32 written= 0;
     168                localnliv4.serialize(opaque_natinfobuf, IE::protocol_v1, written);
    164169                natinfo nat_info;
    165                 nat_info.add(localnliv4);
     170                nat_info.set(opaque_natinfobuf);
    166171
    167172                std::vector<natinfo> txlated_information;
     
    182187                ntobuf_p= new NetMsg(ntobuf_size);
    183188                // should be serialized including the common object header
    184                 uint32 written= 0;
     189                written= 0;
    185190                nto.serialize(*ntobuf_p, IE::protocol_v1, written);
    186191                // object should be completely written into buffer
     
    258263
    259264        gconfig_init gcinit;
     265        AddressList* addresses;
    260266        StatemoduleParam smpar;
    261267
  • ntlp/branches/20090723-multicast/test/test_nattraversal.cpp

    r4108 r4212  
    7474
    7575          natinfo info;
    76           info.add(localnliv4);
     76          string opaque_natinfo="Hello World!"; // 12 bytes
     77          // only ref
     78          NetMsg opaque_natinfo_buf(opaque_natinfo.length());
     79          opaque_natinfo_buf.copy_from(reinterpret_cast<const uchar*>(opaque_natinfo.c_str()), opaque_natinfo.length());
     80
     81          info.set(opaque_natinfo_buf);
     82
     83          // this push will actually copy the NetMsg buffer
    7784          nto->push_natinfo(info);
    7885
     
    137144               
    138145          natinfo info;
    139           info.add(localnliv4);
     146          string opaque_natinfo="Hello World!"; // 12 bytes will require padding of 2 bytes
     147          // only ref
     148          NetMsg opaque_natinfo_buf(opaque_natinfo.length());
     149          opaque_natinfo_buf.copy_from(reinterpret_cast<const uchar*>(opaque_natinfo.c_str()), opaque_natinfo.length());
     150          info.set(opaque_natinfo_buf);
     151          // append a copy of the natinfo object to the list
     152          nto->push_natinfo(info);
     153
     154          string opaque_natinfo2="Second Hello World!!"; // 21 bytes, will require padding of 1 byte
     155          NetMsg opaque_natinfo_buf2(opaque_natinfo2.length());
     156          opaque_natinfo_buf2.copy_from(reinterpret_cast<const uchar*>(opaque_natinfo2.c_str()), opaque_natinfo2.length());
     157          info.set(opaque_natinfo_buf2);
     158          // append a copy of the natinfo object to the list
    140159          nto->push_natinfo(info);
    141160
  • ntlp/branches/20090723-multicast/testing/testbed-uka-setup

Note: See TracChangeset for help on using the changeset viewer.