diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..790c76e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,52 @@ +image: dkr-reg1.mipn:5000/ll_dlep_build:master + +stages: + - build + - test + - deploy + +build: + stage: build + script: + - cd build + - mkdir release + - cmake -DCMAKE_INSTALL_PREFIX:PATH=./release .. + - make install + artifacts: + name: "${CI_PROJECT_NAME}" + paths: + - "build" + +test: + stage: test + script: + - cd build + - make test + +deploy_binaries: + stage: deploy + only: + refs: + - master + variables: + - $CI_PROJECT_NAMESPACE == "netsim/third_party" + variables: + ARCHIVE_NAME: "${CI_PROJECT_NAME}_binaries_${CI_COMMIT_REF_NAME}.tar.gz" + script: + - tar zcf ${ARCHIVE_NAME} ./build/release + - curl -vfs -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} --upload-file "${ARCHIVE_NAME}" "${NEXUS_SIMULATION_THIRD_PARTY_DIR}/${CI_PROJECT_NAME}/${ARCHIVE_NAME}" + +deploy_sources: + stage: deploy + dependencies: [] + only: + refs: + - master + variables: + - $CI_PROJECT_NAMESPACE == "netsim/third_party" + variables: + ARCHIVE_NAME: "${CI_PROJECT_NAME}_src_${CI_COMMIT_REF_NAME}.tar.gz" + script: + - touch "${ARCHIVE_NAME}" + - tar --exclude-vcs --exclude="${ARCHIVE_NAME}" -zcf "${ARCHIVE_NAME}" . + - curl -vfs -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} --upload-file "${ARCHIVE_NAME}" "${NEXUS_SIMULATION_THIRD_PARTY_DIR}/${CI_PROJECT_NAME}/${ARCHIVE_NAME}" diff --git a/CMakeLists.txt b/CMakeLists.txt index bdb174d..19730bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required (VERSION 2.8) project (dlep) +option(BUILD_DOCS "Build Documentation" ON) +option(BUILD_TESTS "Build Tests" ON) + SET(DLEP_VERSION 2.1) # Release version of the software SET(SOVERSION 2.1) # The library version (e.g. libdlep.so.1.0 would be SOVERSION 1.0) @@ -109,8 +112,14 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/package/copyright DESTINATION ${DOCDIR ENABLE_TESTING() add_subdirectory(config) -add_subdirectory(doc) -add_subdirectory(tests) + +if(BUILD_DOCS) + add_subdirectory(doc) +endif(BUILD_DOCS) + +if(BUILD_TESTS) + add_subdirectory(tests) +endif(BUILD_TESTS) # Linux Packaging SET(CPACK_PACKAGE_CONTACT "David P. Wiggins ") diff --git a/Dlep.cpp b/Dlep.cpp index df27941..e5fd91a 100644 --- a/Dlep.cpp +++ b/Dlep.cpp @@ -463,6 +463,20 @@ Dlep::start_dlep() session_acceptor = new boost::asio::ip::tcp::acceptor(io_service_, boost::asio::ip::tcp::endpoint(session_address, session_port)); + + // Set the socket's TTL to the session-ttl config parameter + // if it exists. + try + { + unsigned int ttl; + dlep_client.get_config_parameter("session-ttl", &ttl); + session_acceptor->set_option(boost::asio::ip::unicast::hops(ttl)); + } + catch (const LLDLEP::DlepClient::BadParameterName &) + { + // Let the default TTL take effect. + } + start_async_accept(); } else // we're the router diff --git a/DlepMac.h b/DlepMac.h index 21b6ecc..b6885df 100644 --- a/DlepMac.h +++ b/DlepMac.h @@ -51,12 +51,12 @@ inline void getDifference(const DlepMacAddrs & A, const DlepMacAddrs & B, DlepMacAddrs & C) { // whats in here - for (const auto a : A) + for (const auto& a : A) { bool found = false; // and not in here - for (const auto b : B) + for (const auto& b : B) { if (a == b) { diff --git a/PeerDiscovery.cpp b/PeerDiscovery.cpp index bd55666..a2853e1 100644 --- a/PeerDiscovery.cpp +++ b/PeerDiscovery.cpp @@ -590,9 +590,7 @@ PeerDiscovery::send_peer_offer(boost::asio::ip::udp::endpoint to_endpoint) pm.add_data_item(di_conn_pt); } - boost::asio::ip::udp::endpoint send_endpoint(to_endpoint.address(), - udp_port); - msg << "Sending signal to " << send_endpoint; + msg << "Sending signal to " << to_endpoint; LOG(DLEP_LOG_INFO, msg); // A freshly built message should be parseable. @@ -601,7 +599,7 @@ PeerDiscovery::send_peer_offer(boost::asio::ip::udp::endpoint to_endpoint) assert(err == ""); peer_offer_socket.async_send_to( - boost::asio::buffer(pm.get_buffer(), pm.get_length()), send_endpoint, + boost::asio::buffer(pm.get_buffer(), pm.get_length()), to_endpoint, boost::bind(&PeerDiscovery::handle_send_peer_offer, this, boost::asio::placeholders::error)); } diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index 4454520..15dcb62 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -4,12 +4,14 @@ file(GLOB DRAFTS_XML RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE # gather all xml/xsd files file(GLOB XML_INSTALL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/protocol/*.x[ms][ld]) -foreach ( file ${XML_INSTALL_FILES} ) - add_test(wellformedxml_${file} ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_CURRENT_SOURCE_DIR}/${file}) -endforeach(file) +if(BUILD_TESTS) + foreach ( file ${XML_INSTALL_FILES} ) + add_test(wellformedxml_${file} ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + endforeach(file) -foreach ( file ${DRAFTS_XML} ) - add_test(validatedxml_${file} ${LIBXML2_XMLLINT_EXECUTABLE} --noout --xinclude --schema ${CMAKE_CURRENT_SOURCE_DIR}/protocol/protocol-config.xsd ${CMAKE_CURRENT_SOURCE_DIR}/${file}) -endforeach(file) + foreach ( file ${DRAFTS_XML} ) + add_test(validatedxml_${file} ${LIBXML2_XMLLINT_EXECUTABLE} --noout --xinclude --schema ${CMAKE_CURRENT_SOURCE_DIR}/protocol/protocol-config.xsd ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + endforeach(file) +endif(BUILD_TESTS) install(FILES ${XML_INSTALL_FILES} DESTINATION ${ETCDIR}/dlep) diff --git a/config/modem.xml b/config/modem.xml index 9232108..20e87c7 100644 --- a/config/modem.xml +++ b/config/modem.xml @@ -8,17 +8,20 @@ as a modem. modem 1 - + eth0 - - + 255 + 255 + 4854 - + 225.0.0.117 60 + 255 + 255 - + 4854 60 2 diff --git a/destadvert.proto b/destadvert.proto index ecaf51f..0db201d 100644 --- a/destadvert.proto +++ b/destadvert.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + message DestinationAdvertisement { required uint32 reportinterval = 1; // report interval in seconds required uint32 sequencenumber = 2; // sequence number