Index: source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h
===================================================================
--- source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h	(revision 4851)
+++ source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h	(revision 4853)
@@ -45,4 +45,5 @@
 #include <string>
 #include <iostream>
+#include <boost/asio.hpp>
 #include <boost/foreach.hpp>
 #include <boost/thread/mutex.hpp>
@@ -51,7 +52,9 @@
 #include "ariba/utility/logging/Logging.h"
 #include "ariba/utility/system/Timer.h"
+#include "PeriodicBroadcastMessage.h"
 
 using std::map;
 using std::string;
+using boost::asio::ip::udp;
 
 namespace ariba {
@@ -81,4 +84,6 @@
 
 	static const long timerinterval;
+	static const unsigned int serverport_v4;
+	static const unsigned int serverport_v6;
 
 	typedef struct _Service {
@@ -93,4 +98,104 @@
 	boost::mutex localServicesMutex;
 
+	ServiceList remoteServices;
+	boost::mutex remoteServicesMutex;
+
+	ServiceList newRemoteServices;
+	boost::mutex newRemoteServicesMutex;
+
+	boost::asio::io_service io_service;
+
+	class udp_server {
+	private:
+		udp::socket socket_v4;
+		udp::socket socket_v6;
+		udp::endpoint remote_endpoint_;
+		boost::array<char, 1500> recv_buffer_;
+		ServiceList* services;
+		boost::mutex* servicesmutex;
+
+	public:
+		udp_server(boost::asio::io_service& io_service, ServiceList* _services, boost::mutex* _servicesmutex)
+			: socket_v4(io_service, udp::endpoint(udp::v4(), PeriodicBroadcast::serverport_v4)),
+			  socket_v6(io_service, udp::endpoint(udp::v6(), PeriodicBroadcast::serverport_v6)),
+			  services(_services), servicesmutex(_servicesmutex) {
+
+			boost::asio::socket_base::broadcast option(true);
+			socket_v4.set_option(option);
+			socket_v6.set_option(option);
+
+			start_receive();
+		}
+
+		void sendservice(Service service){
+
+			PeriodicBroadcastMessage msg( service.name, service.info1, service.info2, service.info3 );
+			Data data = data_serialize( msg, DEFAULT_V );
+			uint8_t* pnt = data.getBuffer();
+			size_t len = data.getLength();
+			boost::system::error_code ignored_error;
+
+			{
+				udp::endpoint endp(udp::v4(), PeriodicBroadcast::serverport_v4);
+				endp.address( boost::asio::ip::address_v4::broadcast() );
+				socket_v4.send_to( boost::asio::buffer(pnt, len), endp, 0, ignored_error );
+			}
+			{
+				udp::endpoint endp(udp::v6(), PeriodicBroadcast::serverport_v6);
+				endp.address( boost::asio::ip::address_v6::from_string("ff02::1") );
+				socket_v6.send_to( boost::asio::buffer(pnt, len), endp, 0, ignored_error );
+			}
+		}
+
+	private:
+		void start_receive(){
+			socket_v4.async_receive_from(
+					boost::asio::buffer(recv_buffer_), remote_endpoint_,
+					boost::bind(&udp_server::handle_receive, this,
+							boost::asio::placeholders::error,
+							boost::asio::placeholders::bytes_transferred));
+
+			socket_v6.async_receive_from(
+					boost::asio::buffer(recv_buffer_), remote_endpoint_,
+					boost::bind(&udp_server::handle_receive, this,
+							boost::asio::placeholders::error,
+							boost::asio::placeholders::bytes_transferred));
+		}
+
+		void handle_receive(const boost::system::error_code& error,
+				std::size_t bytes_transferred){
+
+			if (!error || error == boost::asio::error::message_size){
+
+				PeriodicBroadcastMessage msg;
+				Data data( (uint8_t*)recv_buffer_.data(), bytes_transferred*8 );
+				data_deserialize( msg, data );
+
+				{ // insert new found service
+					boost::mutex::scoped_lock( *servicesmutex );
+
+					ServiceList::iterator it = services->find( msg.getName() );
+					if( it != services->end() ) services->erase( it );
+
+					Service s;
+					s.info1 = msg.getInfo1();
+					s.info2 = msg.getInfo2();
+					s.info3 = msg.getInfo3();
+					services->insert( std::make_pair(msg.getName(), s) );
+				}
+
+				start_receive();
+			}
+		}
+
+		void handle_send(boost::shared_ptr<std::string> /*message*/,
+				const boost::system::error_code& /*error*/,
+				std::size_t /*bytes_transferred*/){
+		}
+
+	};
+
+	udp_server server;
+
 };
 
